Skip to content

@liquality.evm.EvmChainProvider

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

Class: EvmChainProvider

@liquality/evm.EvmChainProvider

Represents a connection to any EVM network. Used to fetch chain specific data like blocks, transactions, balances and fees. It uses ethersjs

Example:

import { providers } from 'ethers';
import { EvmNetworks, EvmChainProvider } from '@liquality/evm';

const provider = new providers.StaticJsonRpcProvider(EvmNetworks.ganache.rpcUrl);
const chainProvider = new EvmChainProvider(EvmNetworks.ganache, provider, null);

Hierarchy

  • Chain<StaticJsonRpcProvider>

    EvmChainProvider

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new EvmChainProvider(network, provider?, feeProvider?)

Parameters

Name Type Description
network Network See EvmNetworks
provider? StaticJsonRpcProvider Instance of StaticJsonRpcProvider If not passed, it's created internally based on the rpcUrl from the network parameter.
feeProvider? Fee Instance of Fee. If not passed, it uses getFeeData from the ethers provider.

Overrides

Chain.constructor

Defined in

evm/lib/chain/EvmChainProvider.ts:34

Properties

feeProvider

Protected feeProvider: Fee

Inherited from

Chain.feeProvider

Defined in

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


multicall

Protected multicall: EvmMulticallProvider

Defined in

evm/lib/chain/EvmChainProvider.ts:25


network

Protected network: Network

Inherited from

Chain.network

Defined in

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


provider

Protected provider: StaticJsonRpcProvider

Inherited from

Chain.provider

Defined in

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

Methods

getBalance

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

Parameters

Name Type Description
addresses AddressType[] currently fetches the balances only for addresses[0]
assets Asset[] the list of assets

Returns

Promise<BigNumber[]>

  • the balances of assets in the passed order

Overrides

Chain.getBalance

Defined in

evm/lib/chain/EvmChainProvider.ts:106


getBlockByHash

getBlockByHash(blockHash, includeTx?): Promise<Block<Block | BlockWithTransactions, TransactionResponse>>

Parameters

Name Type Default value Description
blockHash string undefined the hash of the block
includeTx boolean false -

Returns

Promise<Block<Block | BlockWithTransactions, TransactionResponse>>

If includeTx is false the _raw object type is EthersBlock.

If includeTx is true the _raw object type BlockWithTransactions and transactions array with type EthersTransactionResponse

Overrides

Chain.getBlockByHash

Defined in

evm/lib/chain/EvmChainProvider.ts:52


getBlockByNumber

getBlockByNumber(blockNumber?, includeTx?): Promise<Block<Block | BlockWithTransactions, TransactionResponse>>

Parameters

Name Type Default value Description
blockNumber? number undefined the number of the block. If not passed, it fetches the latest block
includeTx boolean false -

Returns

Promise<Block<Block | BlockWithTransactions, TransactionResponse>>

If includeTx is false the _raw object type is EthersBlock.

If includeTx is true the _raw object type BlockWithTransactions and transactions array with type EthersTransactionResponse

Overrides

Chain.getBlockByNumber

Defined in

evm/lib/chain/EvmChainProvider.ts:67


getBlockHeight

getBlockHeight(): Promise<number>

Returns

Promise<number>

resolves with the latest block number

Overrides

Chain.getBlockHeight

Defined in

evm/lib/chain/EvmChainProvider.ts:80


getFeeProvider

getFeeProvider(): Promise<Fee>

Gets the fee provider

Returns

Promise<Fee>

Inherited from

Chain.getFeeProvider

Defined in

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


getFees

getFees(): Promise<FeeDetails>

If the feeProvider is not defined, it fetches the fees from getFeeData

Returns

Promise<FeeDetails>

Overrides

Chain.getFees

Defined in

evm/lib/chain/EvmChainProvider.ts:123


getNetwork

getNetwork(): Network

Gets the connected network

Returns

Network

Inherited from

Chain.getNetwork

Defined in

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


getProvider

getProvider(): StaticJsonRpcProvider

Gets the chain specific provider

Returns

StaticJsonRpcProvider

Inherited from

Chain.getProvider

Defined in

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


getTransactionByHash

getTransactionByHash(txHash): Promise<Transaction<TransactionResponse>>

Parameters

Name Type Description
txHash string the transaction hash prefixed with 0x

Returns

Promise<Transaction<TransactionResponse>>

a transaction object with _raw object type of EthersTransactionResponse

Overrides

Chain.getTransactionByHash

Defined in

evm/lib/chain/EvmChainProvider.ts:89


sendRawTransaction

sendRawTransaction(rawTransaction): Promise<string>

Parameters

Name Type Description
rawTransaction string the signed transaction

Returns

Promise<string>

the hash of the transaction

Overrides

Chain.sendRawTransaction

Defined in

evm/lib/chain/EvmChainProvider.ts:115


sendRpcRequest

sendRpcRequest(method, params): Promise<any>

throws UnsupportedMethodError if the ethers provider doesn't support rpc calls

Parameters

Name Type
method string
params any[]

Returns

Promise<any>

Overrides

Chain.sendRpcRequest

Defined in

evm/lib/chain/EvmChainProvider.ts:140


setFeeProvider

setFeeProvider(feeProvider): Promise<void>

Sets the fee provider

Parameters

Name Type
feeProvider Fee

Returns

Promise<void>

Inherited from

Chain.setFeeProvider

Defined in

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


setNetwork

setNetwork(network): void

Sets the network

Parameters

Name Type
network Network

Returns

void

Inherited from

Chain.setNetwork

Defined in

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


setProvider

setProvider(provider): Promise<void>

Sets the chain specific provider

Parameters

Name Type
provider StaticJsonRpcProvider

Returns

Promise<void>

Inherited from

Chain.setProvider

Defined in

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

Clone this wiki locally