注意: 此页面尚未翻译成中文。以下内容为英文原版。A Provider is the primary method to interact with the read-only content on Ethereum. It allows access to details about accounts, blocks and transactions and the ability to query event logs and simulate contract execution. Account data includes the balance, getTransactionCount, code and state trie storage. Simulating execution can be used to call, estimateGas and get transaction result. The broadcastTransaction is the only method which allows updating the blockchain, but it is usually accessed by a Signer, since a private key must be used to sign the transaction before it can be broadcast.
Property | Type | Description | Overrides | Inherited from |
---|---|---|---|---|
provider | Provider | The provider iteself. This is part of the necessary API for executing a contract, as it provides a common property on any ContractRunner that can be used to access the read-only portion of the runner. | ContractRunner .provider | ContractRunner .provider |
sendTransaction? | (tx : TransactionRequest ) => Promise <TransactionResponse > | Required for state mutating calls | ContractRunner .sendTransaction | ContractRunner .sendTransaction |
Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
zone ? | Zone |
Promise
<Provider
>
EventEmitterable
.addListener
signedTx
to the network, adding it to the memory pool of any node for which the transaction
meets the rebroadcast requirements.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to broadcast the transaction to. |
signedTx | string | The signed transaction to broadcast. |
from ? | AddressLike | The address that signed the transaction. |
Promise
<TransactionResponse
>
A promise resolving to the transaction response.
Parameter | Type | Description |
---|---|---|
from | string | The source address |
to | string | The destination address |
value | BigNumberish | The amount to convert |
Promise
<bigint
>
A promise resolving to the converted amount
Parameter | Type | Description |
---|---|---|
transactionArgs | ConversionTransactionRequest | The transaction arguments containing from, to, and value |
Promise
<bigint
>
A promise resolving to the converted amount
tx
. If the call reverts, it will throw a
CallExceptionError which includes the revert data.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to simulate. |
Promise
<string
>
A promise resolving to the result of the execution.
ContractRunner.call
Parameter | Type | Description |
---|---|---|
tx | QuaiTransactionRequest |
Promise
<AccessList
>
ContractRunner.createAccessList
void
event
with the args
.
Parameter | Type |
---|---|
event | ProviderEvent |
zone ? | Zone |
…args ? | any [] |
Promise
<boolean
>
EventEmitterable
.emit
Parameter | Type | Description |
---|---|---|
tx | QiPerformActionTransaction | The transaction to estimate the fee for. |
Promise
<bigint
>
A promise resolving to the estimated fee.
tx
.
Parameter | Type | Description |
---|---|---|
tx | TransactionRequest | The transaction to estimate the gas for. |
Promise
<bigint
>
A promise resolving to the estimated gas.
ContractRunner.estimateGas
address
. If blockTag
is specified and the node supports archive access
for that blockTag
, the balance is as of that BlockTag.
Parameter | Type | Description |
---|---|---|
address | AddressLike | The address to fetch the balance for. |
blockTag ? | BlockTag | The block tag to fetch the balance from. |
Promise
<bigint
>
A promise resolving to the balance.
blockTag
may be
silently ignored by the node, which may cause issues if relied on.
blockHashOrBlockTag
.
If prefetchTxs
, and the backend supports including transactions with block requests, all transactions will be
included and the Block object will not need to make remote calls for getting transactions.
Parameter | Type | Description |
---|---|---|
shard | Shard | The shard to fetch the block from. |
blockHashOrBlockTag | BlockTag | The block hash or block tag to fetch. |
prefetchTxs ? | boolean | If true, prefetch the transactions. |
Promise
<null
| Block
>
A promise resolving to the block or null if not found.
Parameter | Type | Description |
---|---|---|
shard | Shard | The shard to fetch the block number from. |
Promise
<number
>
A promise resolving to the block number.
address
.
Parameter | Type | Description |
---|---|---|
address | AddressLike | The address to fetch the code for. |
blockTag ? | BlockTag | The block tag to fetch the code from. |
Promise
<string
>
A promise resolving to the code stored at the address.
blockTag
may be
silently ignored by the node, which may cause issues if relied on.
Parameter | Type | Description |
---|---|---|
zone | Zone | The shard to fetch the fee data from. |
txType | boolean | The transaction type to fetch the fee data for (true for Quai, false for Qi) |
Promise
<FeeData
>
A promise resolving to the fee data.
Parameter | Type | Description |
---|---|---|
zone | Zone | - |
amt | bigint | The amount in quais to get the rate for. |
Promise
<bigint
>
A promise resolving to the latest Quai rate.
Parameter | Type | Description |
---|---|---|
zone | Zone | - |
amt | bigint | The amount in quai to get the rate for. |
Promise
<bigint
>
A promise resolving to the latest Quai->Qi rate.
address
.
Parameter | Type | Description |
---|---|---|
address | AddressLike | The address to fetch the locked balance for. |
Promise
<bigint
>
A promise resolving to the locked balance.
filter
Parameter | Type | Description |
---|---|---|
filter | Filter | FilterByBlockHash | The filter to apply. |
Promise
<Log
[]>
A promise resolving to the logs.
Promise
<Network
>
A promise resolving to the network.
address
.
Parameter | Type | Description |
---|---|---|
address | AddressLike | The address to fetch the UTXO entries for. |
Promise
<Outpoint
[]>
A promise resolving to the UTXO entries.
blockTag
may be
silently ignored by the node, which may cause issues if relied on.
Promise
<WorkObjectLike
>
A promise resolving to the work object.
Promise
<number
>
A promise resolving to the current network size.
Parameter | Type | Description |
---|---|---|
zone | Zone | - |
blockTag | BlockTag | - |
amt | bigint | The amount in quais to get the rate for. |
Promise
<bigint
>
A promise resolving to the latest Quai rate.
Parameter | Type | Description |
---|---|---|
zone | Zone | - |
blockTag | BlockTag | - |
amt | bigint | The amount in quais to get the rate for. |
Promise
<bigint
>
A promise resolving to the latest Quai rate.
address
at slot position
.
Parameter | Type | Description |
---|---|---|
address | AddressLike | The address to fetch the storage from. |
position | BigNumberish | The position to fetch the storage from. |
blockTag ? | BlockTag | The block tag to fetch the storage from. |
Promise
<string
>
A promise resolving to the storage value.
blockTag
may be
silently ignored by the node, which may cause issues if relied on.
hash
.
If the transaction is unknown or on pruning nodes which discard old transactions this resolves to null
.
Parameter | Type | Description |
---|---|---|
hash | string | The transaction hash to fetch. |
Promise
<null
| TransactionResponse
| ExternalTransactionResponse
>
A promise resolving to the transaction or null if not found.
address
, which is used as the nonce
when sending a transaction.
If blockTag
is specified and the node supports archive access for that blockTag
, the transaction count is as
of that BlockTag.
Parameter | Type | Description |
---|---|---|
address | AddressLike | The address to fetch the transaction count for. |
blockTag ? | BlockTag | The block tag to fetch the transaction count from. |
Promise
<number
>
A promise resolving to the transaction count.
blockTag
may be
silently ignored by the node, which may cause issues if relied on.
hash
, if mined.
If the transaction has not been mined, is unknown or on pruning nodes which discard old transactions this
resolves to null
.
Parameter | Type | Description |
---|---|---|
hash | string | The transaction hash to fetch the receipt for. |
Promise
<null
| TransactionReceipt
>
A promise resolving to the transaction receipt or null if not
found.
hash
.
This is only supported on nodes with archive access and with the necessary debug APIs enabled.
Parameter | Type | Description |
---|---|---|
hash | string | The transaction hash to fetch the result for. |
Promise
<null
| string
>
A promise resolving to the result or null if not found.
Parameter | Type |
---|---|
zone | Zone |
Promise
<txpoolContentResponse
>
A promise resolving to the transaction pool content.
event
.
Parameter | Type |
---|---|
event ? | ProviderEvent |
Promise
<number
>
EventEmitterable
.listenerCount
event
.
Parameter | Type |
---|---|
event ? | ProviderEvent |
Promise
<Listener
[]>
EventEmitterable
.listeners
listener
for event
. If listener
is unspecified, all listeners are unregistered.
Parameter | Type |
---|---|
event | ProviderEvent |
listener ? | Listener |
zone ? | Zone |
Promise
<Provider
>
EventEmitterable
.off
listener
that is called whenever the event
occurs until unregistered.
Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
zone ? | Zone |
Promise
<Provider
>
EventEmitterable
.on
listener
that is called the next time event
occurs.
Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
zone ? | Zone |
Promise
<Provider
>
EventEmitterable
.once
event
.
Parameter | Type |
---|---|
event ? | ProviderEvent |
Promise
<Provider
>
EventEmitterable
.removeAllListeners
Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
zone ? | Zone |
Promise
<Provider
>
EventEmitterable
.removeListener
Parameter | Type |
---|---|
zone | Zone |
Promise
<txpoolInspectResponse
>
A promise resolving to the transaction pool inspect.
blockTag
once it has been mined.
This can be useful for waiting some number of blocks by using the currentBlockNumber + N
.
Parameter | Type | Description |
---|---|---|
shard | Shard | The shard to fetch the block from. |
blockTag ? | BlockTag | The block tag to fetch. |
Promise
<Block
>
A promise resolving to the block.
hash
is mined and has confirms
confirmations.
Parameter | Type | Description |
---|---|---|
hash | string | The transaction hash to wait for. |
confirms ? | number | The number of confirmations to wait for. |
timeout ? | number | The number of milliseconds to wait before timing out. |
Promise
<null
| TransactionReceipt
>
A promise resolving to the transaction receipt or null if not
found.