- Types
- Functions
- Block
- BrowserProvider
- ContractRunner
- Eip1193Provider
- EnsPlugin
- EventFilter
- FeeData
- FeeDataNetworkPlugin
- Filter
- FilterByBlockHash
- GasCostPlugin
- IpcSocketProvider
- Log
- MinedBlock
- MinedTransactionResponse
- NetworkPlugin
- Networks
- NonceManager
- PreparedTransactionRequest
- Provider
- Signer
- TransactionReceipt
- TransactionRequest
- TransactionResponse
- WebSocketLike
- WebSocketProvider
A Block represents the data associated with a full block on Ethereum.
The number of transactions in this block.
The provider connected to the block used to fetch additional details if necessary.
Returns the complete transactions for blocks which prefetched them, by passing true to prefetchTxs into provider_getBlock.
Create a new Block object.
This should generally not be necessary as the unless implementing a low-level library.
Get the transaction at indexe within this block.
Has this block been mined.
If true, the block has been typed-gaurded that all mined properties are non-null.
Returns a JSON-friendly value.
A FeeData wraps all the fee-related values associated with the network.
The gas price for legacy networks.
The maximum fee to pay per gas.
The base fee per gas is defined by the network and based on congestion, increasing the cost during times of heavy load and lowering when less busy.
The actual fee per gas will be the base fee for the block and the priority fee, up to the max fee per gas.
This will be null on legacy networks (i.e. pre-EIP-1559)
The additional amout to pay per gas to encourage a validator to include the transaction.
The purpose of this is to compensate the validator for the adjusted risk for including a given transaction.
This will be null on legacy networks (i.e. pre-EIP-1559)
Creates a new FeeData for gasPrice, maxFeePerGas and maxPriorityFeePerGas.
Returns a JSON-friendly value.
A Networkish can be used to allude to a Network, by specifing:
- a Network object
- a well-known (or registered) network name
- a well-known (or registered) chain ID
- an object with sufficient details to describe a network
Returns a new Network for the network name or chainId.
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, transaction count, code and state trie storage.
Simulating execution can be used to call, estimate gas and get transaction results.
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.
Broadcasts the signedTx to the network, adding it to the memory pool of any node for which the transaction meets the rebroadcast requirements.
Shutdown any resources this provider is using. No additional calls should be made to this provider after calling this.
Get the account balance (in wei) of address. If blockTag is specified and the node supports archive access for that blockTag, the balance is as of that BlockTag.
Resolves to the block for 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.
Get the current block number.
Get the bytecode for address.
Resolves to the list of Logs that match filter
Get the storage slot value for address at slot position.
Resolves to the transaction for hash.
If the transaction is unknown or on pruning nodes which discard old transactions this resolves to null.
Get the number of transactions ever sent for 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.
Resolves to the transaction receipt for hash, if mined.
If the transaction has not been mined, is unknown or on pruning nodes which discard old transactions this resolves to null.
Resolves to the result returned by the executions of hash.
This is only supported on nodes with archive access and with the necessary debug APIs enabled.
Resolves to the ENS name associated for the address or null if the primary name is not configured.
Users must perform additional steps to configure a primary name, which is not currently common.
Resolves to the block at blockTag once it has been mined.
This can be useful for waiting some number of blocks by using the currentBlockNumber + N.
Waits until the transaction hash is mined and has confirms confirmations.
A Signer represents an account on the Ethereum Blockchain, and is most often backed by a private key represented by a mnemonic or residing on a Hardware Wallet.
The API remains abstract though, so that it can deal with more advanced exotic Signing entities, such as Smart Contract Wallets or Virtual Wallets (where the private key may not be known).
Returns a new instance of this Signer connected to provider or detached from any Provider if null.
Gets the next nonce required for this Signer to send a transaction.
Prepares a {@link TransactionRequest} for calling:
- resolves to and from addresses
- if from is specified , check that it matches this Signer
Prepares a {@link TransactionRequest} for sending to the network by populating any missing properties:
- resolves to and from addresses
- if from is specified , check that it matches this Signer
- populates nonce via signer.getNonce("pending")
- populates gasLimit via signer.estimateGas(tx)
- populates chainId via signer.provider.getNetwork()
- populates type and relevant fee data for that type (gasPrice for legacy transactions, maxFeePerGas for EIP-1559, etc)
Signers an EIP-191 prefixed personal message.
If the message is a string, it is signed as UTF-8 encoded bytes. It is not interpretted as a BytesLike; so the string "0x1234" is signed as six characters, not two bytes.
To sign that example as two bytes, the Uint8Array should be used (i.e. new Uint8Array([ 0x12, 0x34 ])).
Signs tx, returning the fully signed transaction. This does not populate any additional properties within the transaction.
Signs the EIP-712 typed data.
Returns a new TransactionResponse instance which has the ability to detect (and throw an error) if the transaction is replaced, which will begin scanning at startBlock.
This should generally not be used by developers and is intended primarily for internal use. Setting an incorrect startBlock can have devastating performance consequences if used incorrectly.