Skip to content

@liquality.client.Chain

Krasimir Raykov edited this page Mar 30, 2022 · 3 revisions

Class: Chain<T, N>

@liquality/client.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

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/lib/Chain.ts:16

Properties

feeProvider

Protected feeProvider: Fee

Defined in

client/lib/Chain.ts:12


network

Protected network: N

Defined in

client/lib/Chain.ts:13


provider

Protected provider: T

Defined in

client/lib/Chain.ts:14

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/lib/Chain.ts:102


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/lib/Chain.ts:72


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. 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.

Returns

Promise<Block<any, any>>

Implementation of

ChainProvider.getBlockByNumber

Defined in

client/lib/Chain.ts:81


getBlockHeight

Abstract getBlockHeight(): Promise<number>

virtual Get current block height of the chain.

Returns

Promise<number>

Implementation of

ChainProvider.getBlockHeight

Defined in

client/lib/Chain.ts:87


getFeeProvider

getFeeProvider(): Promise<Fee>

Gets the fee provider

Returns

Promise<Fee>

Defined in

client/lib/Chain.ts:60


getFees

Abstract getFees(): Promise<FeeDetails>

virtual

Returns

Promise<FeeDetails>

The fee details - FeeDetails

Defined in

client/lib/Chain.ts:108


getNetwork

getNetwork(): N

Gets the connected network

Returns

N

Defined in

client/lib/Chain.ts:32


getProvider

getProvider(): T

Gets the chain specific provider

Returns

T

Defined in

client/lib/Chain.ts:39


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/lib/Chain.ts:96


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/lib/Chain.ts:117


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/lib/Chain.ts:124


setFeeProvider

setFeeProvider(feeProvider): Promise<void>

Sets the fee provider

Parameters

Name Type
feeProvider Fee

Returns

Promise<void>

Defined in

client/lib/Chain.ts:53


setNetwork

setNetwork(network): void

Sets the network

Parameters

Name Type
network N

Returns

void

Defined in

client/lib/Chain.ts:25


setProvider

setProvider(provider): Promise<void>

Sets the chain specific provider

Parameters

Name Type
provider T

Returns

Promise<void>

Defined in

client/lib/Chain.ts:46

Clone this wiki locally