Skip to content

@liquality.bitcoin.<internal>.Chain

Krasimir Raykov edited this page Mar 30, 2022 · 1 revision

Class: Chain<T, N>

@liquality/bitcoin..Chain

Represents a connection to a specific blockchain. Used to fetch chain specific data like blocks, transactions, balances and fees.

Type parameters

Name Type Description
T T type of the internal provider, e.g. JsonRpcProvider for EVM chains
N Network type of the network. The default value of the type is Network

Hierarchy

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Chain<T, N>(network, provider?, feeProvider?)

Type parameters

Name Type
T T
N Network

Parameters

Name Type
network N
provider? T
feeProvider? Fee

Defined in

client/dist/lib/Chain.d.ts:14

Properties

feeProvider

Protected feeProvider: Fee

Defined in

client/dist/lib/Chain.d.ts:11


network

Protected network: N

Defined in

client/dist/lib/Chain.d.ts:12


provider

Protected provider: T

Defined in

client/dist/lib/Chain.d.ts:13

Methods

getBalance

Abstract getBalance(addresses, assets): Promise<BigNumber[]>

virtual Get the balance for list of accounts and list of assets

Parameters

Name Type
addresses AddressType[]
assets Asset[]

Returns

Promise<BigNumber[]>

Implementation of

ChainProvider.getBalance

Defined in

client/dist/lib/Chain.d.ts:75


getBlockByHash

Abstract getBlockByHash(blockHash, includeTx?): Promise<Block<any, any>>

virtual Get a block given its hash.

throws UnsupportedMethodError - Thrown if the chain doesn't support the method

throws BlockNotFoundError - Thrown if the block doesn't exist

Parameters

Name Type Description
blockHash string A string that represents the hash of the desired block.
includeTx? boolean If true, fetches transactions in the block.

Returns

Promise<Block<any, any>>

Implementation of

ChainProvider.getBlockByHash

Defined in

client/dist/lib/Chain.d.ts:48


getBlockByNumber

Abstract getBlockByNumber(blockNumber?, includeTx?): Promise<Block<any, any>>

virtual Get a block given its number.

Parameters

Name Type Description
blockNumber? number The number of the desired block.
includeTx? boolean -

Returns

Promise<Block<any, any>>

Implementation of

ChainProvider.getBlockByNumber

Defined in

client/dist/lib/Chain.d.ts:57


getBlockHeight

Abstract getBlockHeight(): Promise<number>

virtual Get current block height of the chain.

Returns

Promise<number>

Implementation of

ChainProvider.getBlockHeight

Defined in

client/dist/lib/Chain.d.ts:62


getFeeProvider

getFeeProvider(): Promise<Fee>

Gets the fee provider

Returns

Promise<Fee>

Defined in

client/dist/lib/Chain.d.ts:38


getFees

Abstract getFees(): Promise<FeeDetails>

virtual

Returns

Promise<FeeDetails>

The fee details - FeeDetails

Defined in

client/dist/lib/Chain.d.ts:80


getNetwork

getNetwork(): N

Gets the connected network

Returns

N

Defined in

client/dist/lib/Chain.d.ts:22


getProvider

getProvider(): T

Gets the chain specific provider

Returns

T

Defined in

client/dist/lib/Chain.d.ts:26


getTransactionByHash

Abstract getTransactionByHash(txHash): Promise<Transaction<any>>

virtual Get a transaction given its hash.

Parameters

Name Type Description
txHash string A string that represents the hash of the desired transaction. Resolves with a Transaction with the same hash as the given input.

Returns

Promise<Transaction<any>>

Implementation of

ChainProvider.getTransactionByHash

Defined in

client/dist/lib/Chain.d.ts:70


sendRawTransaction

Abstract sendRawTransaction(rawTransaction): Promise<string>

virtual Broadcast a signed transaction to the network.

throws UnsupportedMethodError - Thrown if the chain doesn't support sending of raw transactions

Parameters

Name Type Description
rawTransaction string A raw transaction usually in the form of a hexadecimal string that represents the serialized transaction.

Returns

Promise<string>

the transaction hash

Defined in

client/dist/lib/Chain.d.ts:88


sendRpcRequest

Abstract sendRpcRequest(method, params): Promise<any>

virtual Used to send supported RPC requests to the RPC node

throws UnsupportedMethodError - Thrown if the chain provider doesn't support RPC requests

Parameters

Name Type
method string
params any[]

Returns

Promise<any>

Defined in

client/dist/lib/Chain.d.ts:94


setFeeProvider

setFeeProvider(feeProvider): Promise<void>

Sets the fee provider

Parameters

Name Type
feeProvider Fee

Returns

Promise<void>

Defined in

client/dist/lib/Chain.d.ts:34


setNetwork

setNetwork(network): void

Sets the network

Parameters

Name Type
network N

Returns

void

Defined in

client/dist/lib/Chain.d.ts:18


setProvider

setProvider(provider): Promise<void>

Sets the chain specific provider

Parameters

Name Type
provider T

Returns

Promise<void>

Defined in

client/dist/lib/Chain.d.ts:30

Clone this wiki locally