-
Notifications
You must be signed in to change notification settings - Fork 69
@liquality.evm.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);
-
Chain
<StaticJsonRpcProvider
>↳
EvmChainProvider
- getBalance
- getBlockByHash
- getBlockByNumber
- getBlockHeight
- getFeeProvider
- getFees
- getNetwork
- getProvider
- getTransactionByHash
- sendRawTransaction
- sendRpcRequest
- setFeeProvider
- setNetwork
- setProvider
• new EvmChainProvider(network
, provider?
, feeProvider?
)
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. |
evm/lib/chain/EvmChainProvider.ts:34
• Protected
feeProvider: Fee
client/dist/lib/Chain.d.ts:11
• Protected
multicall: EvmMulticallProvider
evm/lib/chain/EvmChainProvider.ts:25
• Protected
network: Network
client/dist/lib/Chain.d.ts:12
• Protected
provider: StaticJsonRpcProvider
client/dist/lib/Chain.d.ts:13
▸ getBalance(addresses
, assets
): Promise
<BigNumber
[]>
Name | Type | Description |
---|---|---|
addresses |
AddressType [] |
currently fetches the balances only for addresses[0]
|
assets |
Asset [] |
the list of assets |
Promise
<BigNumber
[]>
- the balances of
assets
in the passed order
evm/lib/chain/EvmChainProvider.ts:106
▸ getBlockByHash(blockHash
, includeTx?
): Promise
<Block
<Block
| BlockWithTransactions
, TransactionResponse
>>
Name | Type | Default value | Description |
---|---|---|---|
blockHash |
string |
undefined |
the hash of the block |
includeTx |
boolean |
false |
- |
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
evm/lib/chain/EvmChainProvider.ts:52
▸ getBlockByNumber(blockNumber?
, includeTx?
): Promise
<Block
<Block
| BlockWithTransactions
, TransactionResponse
>>
Name | Type | Default value | Description |
---|---|---|---|
blockNumber? |
number |
undefined |
the number of the block. If not passed, it fetches the latest block |
includeTx |
boolean |
false |
- |
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
evm/lib/chain/EvmChainProvider.ts:67
▸ getBlockHeight(): Promise
<number
>
Promise
<number
>
resolves with the latest block number
evm/lib/chain/EvmChainProvider.ts:80
▸ getFeeProvider(): Promise
<Fee
>
Gets the fee provider
Promise
<Fee
>
client/dist/lib/Chain.d.ts:38
▸ getFees(): Promise
<FeeDetails
>
If the feeProvider
is not defined, it fetches the fees from getFeeData
Promise
<FeeDetails
>
evm/lib/chain/EvmChainProvider.ts:123
▸ getNetwork(): Network
Gets the connected network
client/dist/lib/Chain.d.ts:22
▸ getProvider(): StaticJsonRpcProvider
Gets the chain specific provider
StaticJsonRpcProvider
client/dist/lib/Chain.d.ts:26
▸ getTransactionByHash(txHash
): Promise
<Transaction
<TransactionResponse
>>
Name | Type | Description |
---|---|---|
txHash |
string |
the transaction hash prefixed with 0x
|
Promise
<Transaction
<TransactionResponse
>>
a transaction object with _raw object type of EthersTransactionResponse
evm/lib/chain/EvmChainProvider.ts:89
▸ sendRawTransaction(rawTransaction
): Promise
<string
>
Name | Type | Description |
---|---|---|
rawTransaction |
string |
the signed transaction |
Promise
<string
>
the hash of the transaction
evm/lib/chain/EvmChainProvider.ts:115
▸ sendRpcRequest(method
, params
): Promise
<any
>
throws
UnsupportedMethodError if the ethers provider doesn't support rpc calls
Name | Type |
---|---|
method |
string |
params |
any [] |
Promise
<any
>
evm/lib/chain/EvmChainProvider.ts:140
▸ setFeeProvider(feeProvider
): Promise
<void
>
Sets the fee provider
Name | Type |
---|---|
feeProvider |
Fee |
Promise
<void
>
client/dist/lib/Chain.d.ts:34
▸ setNetwork(network
): void
Sets the network
Name | Type |
---|---|
network |
Network |
void
client/dist/lib/Chain.d.ts:18
▸ setProvider(provider
): Promise
<void
>
Sets the chain specific provider
Name | Type |
---|---|
provider |
StaticJsonRpcProvider |
Promise
<void
>
client/dist/lib/Chain.d.ts:30