-
Notifications
You must be signed in to change notification settings - Fork 70
@liquality.client.Chain
@liquality/client.Chain
Represents a connection to a specific blockchain. Used to fetch chain specific data like blocks, transactions, balances and fees.
| 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 |
- getBalance
- getBlockByHash
- getBlockByNumber
- getBlockHeight
- getFeeProvider
- getFees
- getNetwork
- getProvider
- getTransactionByHash
- sendRawTransaction
- sendRpcRequest
- setFeeProvider
- setNetwork
- setProvider
• new Chain<T, N>(network, provider?, feeProvider?)
| Name | Type |
|---|---|
T |
T |
N |
Network |
| Name | Type |
|---|---|
network |
N |
provider? |
T |
feeProvider? |
Fee |
• Protected feeProvider: Fee
• Protected network: N
• Protected provider: T
▸ Abstract getBalance(addresses, assets): Promise<BigNumber[]>
virtual
Get the balance for list of accounts and list of assets
| Name | Type |
|---|---|
addresses |
AddressType[] |
assets |
Asset[] |
Promise<BigNumber[]>
▸ 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
| Name | Type | Description |
|---|---|---|
blockHash |
string |
A string that represents the hash of the desired block. |
includeTx? |
boolean |
If true, fetches transactions in the block. |
Promise<Block<any, any>>
▸ Abstract getBlockByNumber(blockNumber?, includeTx?): Promise<Block<any, any>>
virtual
Get a block given its number.
| Name | Type | Description |
|---|---|---|
blockNumber? |
number |
The number of the desired block. If the blockNumber is missing, it returns the latest block |
includeTx? |
boolean |
If true, fetches transaction in the block. Resolves with a Block with the same number as the given input. |
Promise<Block<any, any>>
ChainProvider.getBlockByNumber
▸ Abstract getBlockHeight(): Promise<number>
virtual
Get current block height of the chain.
Promise<number>
▸ getFeeProvider(): Promise<Fee>
Gets the fee provider
Promise<Fee>
▸ Abstract getFees(): Promise<FeeDetails>
virtual
Promise<FeeDetails>
The fee details - FeeDetails
▸ getNetwork(): N
Gets the connected network
N
▸ getProvider(): T
Gets the chain specific provider
T
▸ Abstract getTransactionByHash(txHash): Promise<Transaction<any>>
virtual
Get a transaction given its hash.
| 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. |
Promise<Transaction<any>>
ChainProvider.getTransactionByHash
▸ 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
| Name | Type | Description |
|---|---|---|
rawTransaction |
string |
A raw transaction usually in the form of a hexadecimal string that represents the serialized transaction. |
Promise<string>
the transaction hash
▸ 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
| Name | Type |
|---|---|
method |
string |
params |
any[] |
Promise<any>
▸ setFeeProvider(feeProvider): Promise<void>
Sets the fee provider
| Name | Type |
|---|---|
feeProvider |
Fee |
Promise<void>
▸ setNetwork(network): void
Sets the network
| Name | Type |
|---|---|
network |
N |
void
▸ setProvider(provider): Promise<void>
Sets the chain specific provider
| Name | Type |
|---|---|
provider |
T |
Promise<void>