eth
Index
References
Namespaces
Classes
Interfaces
Type Aliases
Variables
- ALL_EVENTS
- ALL_EVENTS_ABI
- NUMBER_DATA_FORMAT
- SignatureObjectSchema
- accessListItemSchema
- accessListResultSchema
- accessListSchema
- accountSchema
- blockHeaderSchema
- blockSchema
- chainSchema
- customChainSchema
- feeHistorySchema
- hardforkSchema
- logSchema
- registeredSubscriptions
- storageProofSchema
- syncSchema
- transactionInfoSchema
- transactionReceiptSchema
- transactionSchema
- withdrawalsSchema
Functions
- call
- createAccessList
- detectTransactionType
- estimateGas
- formatTransaction
- getBalance
- getBlock
- getBlockNumber
- getBlockTransactionCount
- getBlockUncleCount
- getChainId
- getCode
- getCoinbase
- getFeeHistory
- getGasPrice
- getHashRate
- getLogs
- getMaxPriorityFeePerGas
- getPendingTransactions
- getProof
- getProtocolVersion
- getStorageAt
- getTransaction
- getTransactionCount
- getTransactionFromBlock
- getTransactionFromOrToAttr
- getTransactionReceipt
- getUncle
- isAccessList
- isAccessListEntry
- isBaseTransaction
- isMining
- isSyncing
- isTransaction1559Unsigned
- isTransaction2930Unsigned
- isTransactionCall
- isTransactionLegacyUnsigned
- isTransactionWithSender
- prepareTransactionForSigning
- sendSignedTransaction
- sendTransaction
- sign
- signTransaction
- signTypedData
- transactionBuilder
- trySendTransaction
- validateBaseChain
- validateChainInfo
- validateCustomChainInfo
- validateFeeMarketGas
- validateGas
- validateHardfork
- validateLegacyGas
- validateTransactionCall
- validateTransactionForSigning
- validateTransactionWithSender
- waitForTransactionReceipt
References
Web3Eth
decodeEventABI
Namespaces
abi
decodeContractErrorData
Parameters
errorsAbi: AbiErrorFragment[]
error: Eip838ExecutionError
Returns void
decodeFunctionCall
Parameters
functionsAbi: AbiFunctionFragment | AbiConstructorFragment
The
JSON interface
object of the function.data: string
The data to decode
optionalmethodSignatureProvided: boolean
(Optional) if
false
do not remove the first 4 bytes that would rather contain the function signature.
Returns DecodedParams & { __method__: string }
- The data decoded according to the passed ABI.
decodeFunctionReturn
Decodes a function call data using its
JSON interface
object. The JSON interface spec documentation https://docs.soliditylang.org/en/latest/abi-spec.html#jsonParameters
functionsAbi: AbiFunctionFragment
The
JSON interface
object of the function.optionalreturnValues: string
The data (the function-returned-values) to decoded
Returns unknown
- The ABI encoded function call, which, means the function signature and the parameters passed.
decodeLog
Decodes ABI-encoded log data and indexed topic data.
Type parameters
- ReturnType_1: DecodedParams<ReturnType_1>
Parameters
inputs: readonly AbiParameter[] | AbiParameter[]
A AbiParameter input array. See the Solidity documentation for a list of types.
data: string
The ABI byte code in the
data
field of a log.topics: string | string[]
An array with the index parameter topics of the log, without the topic[0] if its a non-anonymous event, otherwise with topic[0]
Returns ReturnType_1
- The result object containing the decoded parameters.
decodeParameter
Decodes an ABI encoded parameter to its JavaScript type.
Parameters
abi: AbiInput
The type of the parameter. See the Solidity documentation for a list of types.
bytes: string
The ABI byte code to decode
Returns unknown
- The decoded parameter
decodeParameters
Decodes ABI encoded parameters to its JavaScript types.
Parameters
abi: readonly AbiInput[] | AbiInput[]
An array of AbiInput. See the Solidity documentation for a list of types.
bytes: string
The ABI byte code to decode
Returns { __length__: number }
- The result object containing the decoded parameters.
[key string]: unknown
__length__: number
decodeParametersWith
encodeErrorSignature
Encodes the error name to its ABI signature, which are the sha3 hash of the error name including input types.
Parameters
functionName: string | AbiErrorFragment
Returns string
encodeEventSignature
Encodes the event name to its ABI signature, which are the sha3 hash of the event name including input types.
Parameters
functionName: string | AbiEventFragment
The event name to encode, or the AbiEventFragment object of the event. If string, it has to be in the form of
eventName(param1Type,param2Type,...)
. eg: myEvent(uint256,bytes32).
Returns string
- The ABI signature of the event.
encodeFunctionCall
Encodes a function call using its
JSON interface
object and given parameters. The JSON interface spec documentation https://docs.soliditylang.org/en/latest/abi-spec.html#jsonParameters
jsonInterface: AbiFunctionFragment
The
JSON interface
object of the function.params: unknown[]
The parameters to encode
Returns string
- The ABI encoded function call, which, means the function signature and the parameters passed.
encodeFunctionSignature
Encodes the function name to its ABI representation, which are the first 4 bytes of the sha3 of the function name including types. The JSON interface spec documentation https://docs.soliditylang.org/en/latest/abi-spec.html#json
Parameters
functionName: string | AbiFunctionFragment
The function name to encode or the
JSON interface
object of the function. If the passed parameter is a string, it has to be in the form offunctionName(param1Type,param2Type,...)
. eg: myFunction(uint256,uint32[],bytes10,bytes)
Returns string
- The ABI signature of the function.
encodeParameter
Encodes a parameter based on its type to its ABI representation.
Parameters
abi: AbiInput
The type of the parameter. See the Solidity documentation for a list of types.
param: unknown
The actual parameter to encode.
Returns string
- The ABI encoded parameter
encodeParameters
Encodes a parameter based on its type to its ABI representation.
Parameters
abi: readonly AbiInput[]
An array of AbiInput. See Solidity's documentation for more details.
params: unknown[]
The actual parameters to encode.
Returns string
- The ABI encoded parameters
flattenTypes
used to flatten json abi inputs/outputs into an array of type-representing-strings
Parameters
includeTuple: boolean
puts: readonly AbiParameter[]
Returns string[]
formatOddHexstrings
format odd-length bytes to even-length
Parameters
param: string
Returns string
formatParam
Handle some formatting of params for backwards compatibility with Ethers V4
Parameters
type: string
_param: unknown
Returns unknown
getEncodedEip712Data
Get the EIP-191 encoded message to sign, from the typedData object. If
hash
is enabled, the message will be hashed with Keccak256.Parameters
typedData: Eip712TypedData
optionalhash: boolean
Returns string
inferTypesAndEncodeParameters
Infer a smart contract method parameter type and then encode this parameter.
Parameters
params: unknown[]
The parameters to encode.
Returns string
- The ABI encoded parameters
isAbiConstructorFragment
Parameters
item: unknown
Returns item is AbiConstructorFragment
isAbiErrorFragment
Parameters
item: unknown
Returns item is AbiEventFragment
isAbiEventFragment
Parameters
item: unknown
Returns item is AbiEventFragment
isAbiFragment
Parameters
item: unknown
Returns item is AbiFragment
isAbiFunctionFragment
Parameters
item: unknown
Returns item is AbiFunctionFragment
isOddHexstring
returns true if input is a hexstring and is odd-lengthed
Parameters
param: unknown
Returns boolean
isSimplifiedStructFormat
Check if type is simplified struct format
Parameters
type: Partial<AbiParameter> | Partial<AbiInput>
Returns type is Omit<AbiParameter, name | components>
jsonInterfaceMethodToString
Should be used to create full function/event name from json abi returns a string
Parameters
json: AbiFragment
Returns string
mapStructNameAndType
Maps the correct tuple type and name when the simplified format in encode/decodeParameter is used
Parameters
structName: string
Returns AbiStruct
mapStructToCoderFormat
Maps the simplified format in to the expected format of the ABICoder
Parameters
struct: AbiStruct
Returns AbiCoderStruct[]
mapTypes
Map types if simplified format is used
Parameters
types: AbiInput[]
Returns (string | Record<string, unknown> | AbiParameter)[]
accounts
txUtils
checkMaxInitCodeSize
Parameters
common: Common
length: number
Returns void
getAccessListData
Parameters
accessList: AccessListUint8Array | AccessList
Returns { AccessListJSON: AccessList; accessList: AccessListUint8Array }
AccessListJSON: AccessList
accessList: AccessListUint8Array
getAccessListJSON
Parameters
accessList: AccessListUint8Array
Returns { address: string; storageKeys: string[] }[]
getDataFeeEIP2930
Parameters
accessList: AccessListUint8Array
common: Common
Returns number
verifyAccessList
Parameters
accessList: AccessListUint8Array
Returns void
Capability
Can be used in conjunction with Transaction.supports to query on tx capabilities
EIP1559FeeMarket
Tx supports EIP-1559 gas fee market mechanism See: 1559 Fee Market EIP
EIP155ReplayProtection
Tx supports EIP-155 replay protection See: 155 Replay Attack Protection EIP
EIP2718TypedTransaction
Tx is a typed transaction as defined in EIP-2718 See: 2718 Transaction Type EIP
EIP2930AccessLists
Tx supports access list generation as defined in EIP-2930 See: 2930 Access Lists EIP
Chain
Goerli
Mainnet
Sepolia
ConsensusAlgorithm
Casper
Clique
Ethash
ConsensusType
ProofOfAuthority
ProofOfStake
ProofOfWork
CustomChain
ArbitrumOne
Arbitrum One - mainnet for Arbitrum roll-up
ArbitrumRinkebyTestnet
Arbitrum Rinkeby Testnet
OptimisticEthereum
Optimistic Ethereum - mainnet for Optimism roll-up
OptimisticKovan
Optimistic Kovan - testnet for Optimism roll-up
PolygonMainnet
Polygon (Matic) Mainnet
PolygonMumbai
Polygon (Matic) Mumbai Testnet
xDaiChain
xDai EVM sidechain with a native stable token
Hardfork
ArrowGlacier
Berlin
Byzantium
Chainstart
Constantinople
Dao
GrayGlacier
Homestead
Istanbul
London
Merge
MergeForkIdTransition
MuirGlacier
Petersburg
Shanghai
ShardingForkDev
SpuriousDragon
TangerineWhistle
TypeOutput
Type output options
BigInt
Number
PrefixedHexString
Uint8Array
AccessListEIP2930Transaction
Typed transaction with optional access lists
- TransactionType: 1
- EIP: EIP-2930
constructor
This constructor takes the values, validates them, assigns them and freezes the object.
It is not recommended to use this constructor directly. Instead use the static factory methods to assist in creating a Transaction object from varying data types.
Parameters
txData: AccessListEIP2930TxData
optionalopts: TxOptions
Returns AccessListEIP2930Transaction
readonlyAccessListJSON
readonlyaccessList
readonlychainId
readonlycommon
readonlydata
readonlygasLimit
readonlygasPrice
readonlynonce
optionalreadonlyr
optionalreadonlys
optionalreadonlyto
optionalreadonlyv
readonlyvalue
type
Returns the transaction type.
Note: legacy txs will return tx type
0
.Returns number
_processSignature
Parameters
v: bigint
r: Uint8Array
s: Uint8Array
Returns AccessListEIP2930Transaction
errorStr
Return a compact error string representation of the object
Returns string
getBaseFee
The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
Returns bigint
getDataFee
The amount of gas paid for the data in this tx
Returns bigint
getMessageToSign
Returns the serialized unsigned tx (hashed or raw), which can be used to sign the transaction (e.g. for sending to a hardware wallet).
Note: in contrast to the legacy tx the raw message format is already serialized and doesn't need to be RLP encoded any more.
const serializedMessage = tx.getMessageToSign(false) // use this for the HW wallet input
Parameters
optionalhashMessage: boolean
Return hashed message if set to true (default: true)
Returns Uint8Array
getMessageToVerifySignature
Computes a sha3-256 hash which can be used to verify the signature
Returns Uint8Array
getSenderAddress
Returns the sender's address
Returns Address
getSenderPublicKey
Returns the public key of the sender
Returns Uint8Array
getUpfrontCost
The up front amount that an account must have for this transaction to be valid
Returns bigint
hash
Computes a sha3-256 hash of the serialized tx.
This method can only be used for signed txs (it throws otherwise). Use AccessListEIP2930Transaction.getMessageToSign to get a tx hash for the purpose of signing.
Returns Uint8Array
isSigned
Returns boolean
raw
Returns a Uint8Array Array of the raw Uint8Arrays of the EIP-2930 transaction, in order.
Format:
[chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)]Use AccessListEIP2930Transaction.serialize to add a transaction to a block with Block.fromValuesArray.
For an unsigned tx this method uses the empty UINT8ARRAY values for the signature parameters
v
,r
ands
for encoding. For an EIP-155 compliant representation for external signing use AccessListEIP2930Transaction.getMessageToSign.Returns AccessListEIP2930ValuesArray
serialize
Returns the serialized encoding of the EIP-2930 transaction.
Format:
0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)])Note that in contrast to the legacy tx serialization format this is not valid RLP any more due to the raw tx type preceding and concatenated to the RLP encoding of the values.
Returns Uint8Array
sign
Signs a transaction.
Note that the signed tx is returned as a new object, use as follows:
const signedTx = tx.sign(privateKey)
Parameters
privateKey: Uint8Array
Returns AccessListEIP2930Transaction
supports
Checks if a tx type defining capability is active on a tx, for example the EIP-1559 fee market mechanism or the EIP-2930 access list feature.
Note that this is different from the tx type itself, so EIP-2930 access lists can very well be active on an EIP-1559 tx for example.
This method can be useful for feature checks if the tx type is unknown (e.g. when instantiated with the tx factory).
See
Capabilites
in thetypes
module for a reference on all supported capabilities.Parameters
capability: Capability
Returns boolean
toCreationAddress
If the tx's
to
is to the creation addressReturns boolean
toJSON
Returns an object with the JSON representation of the transaction
Returns JsonTx
validate
Checks if the transaction has the minimum amount of gas required (DataFee + TxFee + Creation Fee).
Returns boolean
verifySignature
Determines if the signature is valid
Returns boolean
staticfromSerializedTx
Instantiate a transaction from the serialized tx.
Format:
0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)])Parameters
serialized: Uint8Array
optionalopts: TxOptions
Returns AccessListEIP2930Transaction
staticfromTxData
Instantiate a transaction from a data dictionary.
Format: { chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, v, r, s }
Notes:
chainId
will be set automatically if not provided- All parameters are optional and have some basic default values
Parameters
txData: AccessListEIP2930TxData
optionalopts: TxOptions
Returns AccessListEIP2930Transaction
staticfromValuesArray
Create a transaction from a values array.
Format:
[chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)]Parameters
values: AccessListEIP2930ValuesArray
optionalopts: TxOptions
Returns AccessListEIP2930Transaction
abstractBaseTransaction
This base class will likely be subject to further refactoring along the introduction of additional tx types on the Ethereum network.
It is therefore not recommended to use directly.
Type parameters
- TransactionObject
constructor
Type parameters
- TransactionObject
Parameters
txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData
opts: TxOptions
Returns BaseTransaction<TransactionObject>
readonlycommon
readonlydata
readonlygasLimit
readonlynonce
optionalreadonlyr
optionalreadonlys
optionalreadonlyto
optionalreadonlyv
readonlyvalue
type
Returns the transaction type.
Note: legacy txs will return tx type
0
.Returns number
abstracterrorStr
Return a compact error string representation of the object
Returns string
getBaseFee
The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
Returns bigint
getDataFee
The amount of gas paid for the data in this tx
Returns bigint
abstractgetMessageToSign
Parameters
hashMessage: false
Returns Uint8Array | Uint8Array[]
abstractgetMessageToVerifySignature
Returns Uint8Array
getSenderAddress
Returns the sender's address
Returns Address
abstractgetSenderPublicKey
Returns the public key of the sender
Returns Uint8Array
abstractgetUpfrontCost
The up front amount that an account must have for this transaction to be valid
Returns bigint
abstracthash
Returns Uint8Array
isSigned
Returns boolean
abstractraw
Returns a Uint8Array Array of the raw Uint8Arrays of this transaction, in order.
Use BaseTransaction.serialize to add a transaction to a block with Block.fromValuesArray.
For an unsigned tx this method uses the empty Uint8Array values for the signature parameters
v
,r
ands
for encoding. For an EIP-155 compliant representation for external signing use BaseTransaction.getMessageToSign.Returns FeeMarketEIP1559ValuesArray | AccessListEIP2930ValuesArray | TxValuesArray
abstractserialize
Returns the encoding of the transaction.
Returns Uint8Array
sign
Signs a transaction.
Note that the signed tx is returned as a new object, use as follows:
const signedTx = tx.sign(privateKey)
Parameters
privateKey: Uint8Array
Returns TransactionObject
supports
Checks if a tx type defining capability is active on a tx, for example the EIP-1559 fee market mechanism or the EIP-2930 access list feature.
Note that this is different from the tx type itself, so EIP-2930 access lists can very well be active on an EIP-1559 tx for example.
This method can be useful for feature checks if the tx type is unknown (e.g. when instantiated with the tx factory).
See
Capabilites
in thetypes
module for a reference on all supported capabilities.Parameters
capability: Capability
Returns boolean
toCreationAddress
If the tx's
to
is to the creation addressReturns boolean
abstracttoJSON
Returns an object with the JSON representation of the transaction
Returns JsonTx
validate
Checks if the transaction has the minimum amount of gas required (DataFee + TxFee + Creation Fee).
Returns boolean
verifySignature
Determines if the signature is valid
Returns boolean
staticfromSerializedTx
Parameters
serialized: Uint8Array
optionalopts: TxOptions
Returns any
staticfromTxData
Parameters
txData: any
optionalopts: TxOptions
Returns any
Common
Common class to access chain and hardfork parameters and to provide a unified and shared view on the network and hardfork state.
Use the Common.custom static constructor for creating simple custom chain Common objects (more complete custom chain setups can be created via the main constructor and the CommonOpts.customChains parameter).
constructor
Parameters
opts: CommonOpts
Returns Common
readonlyDEFAULT_HARDFORK
_calcForkHash
Internal helper function to calculate a fork hash
Parameters
hardfork: string
Hardfork name
genesisHash: Uint8Array
Genesis block hash of the chain
Returns string
Fork hash as hex string
_getHardfork
Internal helper function, returns the params for the given hardfork for the chain set
Parameters
hardfork: string
Hardfork name
Returns null | HardforkConfig
Dictionary with hardfork params or null if hardfork not on chain
activeOnBlock
Alias to hardforkIsActiveOnBlock when hardfork is set
Parameters
blockNumber: Numbers
Returns boolean
True if HF is active on block number
bootstrapNodes
Returns bootstrap nodes for the current chain
Returns undefined | BootstrapNodeConfig[]
Dict with bootstrap nodes
chainId
Returns the Id of current chain
Returns bigint
chain Id
chainName
Returns the name of current chain
Returns string
chain name (lower case)
consensusAlgorithm
Returns the concrete consensus implementation algorithm or protocol for the network e.g. "ethash" for "pow" consensus type, "clique" for "poa" consensus type or "casper" for "pos" consensus type.
Note: This value can update along a Hardfork.
Returns string
consensusConfig
Returns a dictionary with consensus configuration parameters based on the consensus algorithm
Expected returns (parameters must be present in the respective chain json files):
ethash: empty object clique: period, epoch casper: empty object
Note: This value can update along a Hardfork.
Returns {}
[key string]: CliqueConfig | EthashConfig | CasperConfig
consensusType
Returns the consensus type of the network Possible values: "pow"|"poa"|"pos"
Note: This value can update along a Hardfork.
Returns string
copy
Returns a deep copy of this Common instance.
Returns Common
dnsNetworks
Returns DNS networks for the current chain
Returns string[]
Array of DNS ENR urls
eipBlock
Returns the hardfork change block for eip
Parameters
eip: number
EIP number
Returns null | bigint
Block number or null if unscheduled
eips
Returns the active EIPs
Returns number[]
List of EIPs
forkHash
Returns an eth/64 compliant fork hash (EIP-2124)
Parameters
optional_hardfork: string
optionalgenesisHash: Uint8Array
Genesis block hash of the chain, optional if already defined and not needed to be calculated
Returns string
genesis
Returns the Genesis parameters of the current chain
Returns GenesisBlockConfig
Genesis dictionary
getHardforkByBlockNumber
Returns the hardfork based on the block number or an optional total difficulty (Merge HF) provided.
An optional TD takes precedence in case the corresponding HF block is set to
null
or otherwise needs to match (if not an error will be thrown).Parameters
Returns string
The name of the HF
getMaxListeners
Returns number
gteHardfork
Alias to hardforkGteHardfork when hardfork is set
Parameters
hardfork: string
Hardfork name
Returns boolean
True if hardfork set is greater than hardfork provided
hardfork
Returns the hardfork set
Returns string
Hardfork name
hardforkBlock
Returns the hardfork change block for hardfork provided or set
Parameters
optional_hardfork: string
Returns null | bigint
Block number or null if unscheduled
hardforkForForkHash
Parameters
forkHash: string
Fork hash as a hex string
Returns null | HardforkConfig
Array with hardfork data (name, block, forkHash)
hardforkGteHardfork
Sequence based check if given or set HF1 is greater than or equal HF2
Parameters
_hardfork1: null | string
hardfork2: string
Hardfork name
Returns boolean
True if HF1 gte HF2
hardforkIsActiveOnBlock
Checks if set or provided hardfork is active on block number
Parameters
_hardfork: null | string
_blockNumber: Numbers
Returns boolean
True if HF is active on block number
hardforkTTD
Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set
Parameters
optional_hardfork: string
Returns null | bigint
Total difficulty or null if no set
hardforkTimestamp
Parameters
optional_hardfork: string
Returns null | bigint
hardforks
Returns the hardforks for current chain
Returns HardforkConfig[]
Array with arrays of hardforks
isActivatedEIP
Checks if an EIP is activated by either being included in the EIPs manually passed in with the CommonOpts.eips or in a hardfork currently being active
Note: this method only works for EIPs being supported by the CommonOpts.eips constructor option
Parameters
eip: number
Returns boolean
isHardforkBlock
True if block number provided is the hardfork (given or set) change block
Parameters
_blockNumber: Numbers
optional_hardfork: string
Returns boolean
True if blockNumber is HF block
isNextHardforkBlock
True if block number provided is the hardfork change block following the hardfork given or set
Parameters
_blockNumber: Numbers
optional_hardfork: string
Returns boolean
True if blockNumber is HF block
networkId
Returns the Id of current network
Returns bigint
network Id
nextHardforkBlock
Returns the change block for the next hardfork after the hardfork provided or set
Parameters
optional_hardfork: string
Returns null | bigint
Block number or null if not available
nextHardforkBlockOrTimestamp
Returns the change block for the next hardfork after the hardfork provided or set
Parameters
optional_hardfork: string
Returns null | bigint
Block timestamp, number or null if not available
param
Returns a parameter for the current chain setup
If the parameter is present in an EIP, the EIP always takes precedence. Otherwise the parameter if taken from the latest applied HF with a change on the respective parameter.
Parameters
topic: string
Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow')
name: string
Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
Returns bigint
The value requested or
BigInt(0)
if not found
paramByBlock
Returns a parameter for the hardfork active on block number or optional provided total difficulty (Merge HF)
Parameters
topic: string
Parameter topic
name: string
Parameter name
blockNumber: Numbers
Block number
optionaltd: Numbers
Total difficulty *
optionaltimestamp: Numbers
Returns bigint
The value requested or
BigInt(0)
if not found
paramByEIP
Returns a parameter corresponding to an EIP
Parameters
topic: string
Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow')
name: string
Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
eip: number
Number of the EIP
Returns undefined | bigint
The value requested or
undefined
if not found
paramByHardfork
Returns the parameter corresponding to a hardfork
Parameters
topic: string
Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow')
name: string
Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
hardfork: string
Hardfork name
Returns bigint
The value requested or
BigInt(0)
if not found
setChain
Sets the chain
Parameters
chain: string | number | bigint | object
String ('mainnet') or Number (1) chain representation. Or, a Dictionary of chain parameters for a private network.
Returns ChainConfig
The dictionary with parameters set as chain
setEIPs
Sets the active EIPs
Parameters
optionaleips: number[]
Returns void
setForkHashes
Sets any missing forkHashes on the passed-in Common instance
Parameters
genesisHash: Uint8Array
The genesis block hash
Returns void
setHardfork
Sets the hardfork to get params for
Parameters
hardfork: string
String identifier (e.g. 'byzantium') or Hardfork enum
Returns void
setHardforkByBlockNumber
Sets a new hardfork based on the block number or an optional total difficulty (Merge HF) provided.
An optional TD takes precedence in case the corresponding HF block is set to
null
or otherwise needs to match (if not an error will be thrown).Parameters
Returns string
The name of the HF set
setMaxListeners
Parameters
maxListeners: number
Returns this
static_getInitializedChains
Parameters
optionalcustomChains: ChainConfig[]
Returns ChainsConfig
staticcustom
Creates a Common object for a custom chain, based on a standard one.
It uses all the Chain parameters from the baseChain option except the ones overridden in a provided chainParamsOrName dictionary. Some usage example:
Common.custom({chainId: 123})
There are also selected supported custom chains which can be initialized by using one of the CustomChains for chainParamsOrName, e.g.:
Common.custom(CustomChains.MaticMumbai)
Note that these supported custom chains only provide some base parameters (usually the chain and network ID and a name) and can only be used for selected use cases (e.g. sending a tx with the
web3-utils/tx
library to a Layer-2 chain).Parameters
chainParamsOrName: Partial<ChainConfig> | CustomChain
Custom parameter dict (
name
will default tocustom-chain
) or string with name of a supported custom chainoptionalopts: CustomCommonOpts
Custom chain options to set the CustomCommonOpts.baseChain, selected CustomCommonOpts.hardfork and others
Returns Common
staticfromGethGenesis
Static method to load and set common from a geth genesis json
Parameters
genesisJson: any
json of geth configuration
to: GethConfigOpts
further configure the common instance
Returns Common
Common
staticisSupportedChainId
Static method to determine if a chainId is supported as a standard chain
Parameters
chainId: bigint
bigint id (
1
) of a standard chain
Returns boolean
boolean
FeeMarketEIP1559Transaction
Typed transaction with a new gas fee market mechanism
- TransactionType: 2
- EIP: EIP-1559
constructor
This constructor takes the values, validates them, assigns them and freezes the object.
It is not recommended to use this constructor directly. Instead use the static factory methods to assist in creating a Transaction object from varying data types.
Parameters
txData: FeeMarketEIP1559TxData
optionalopts: TxOptions
Returns FeeMarketEIP1559Transaction
readonlyAccessListJSON
readonlyaccessList
readonlychainId
readonlycommon
readonlydata
readonlygasLimit
readonlymaxFeePerGas
readonlymaxPriorityFeePerGas
readonlynonce
optionalreadonlyr
optionalreadonlys
optionalreadonlyto
optionalreadonlyv
readonlyvalue
type
Returns the transaction type.
Note: legacy txs will return tx type
0
.Returns number
_processSignature
Parameters
v: bigint
r: Uint8Array
s: Uint8Array
Returns FeeMarketEIP1559Transaction
errorStr
Return a compact error string representation of the object
Returns string
getBaseFee
The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
Returns bigint
getDataFee
The amount of gas paid for the data in this tx
Returns bigint
getMessageToSign
Returns the serialized unsigned tx (hashed or raw), which can be used to sign the transaction (e.g. for sending to a hardware wallet).
Note: in contrast to the legacy tx the raw message format is already serialized and doesn't need to be RLP encoded any more.
const serializedMessage = tx.getMessageToSign(false) // use this for the HW wallet input
Parameters
optionalhashMessage: boolean
Return hashed message if set to true (default: true)
Returns Uint8Array
getMessageToVerifySignature
Computes a sha3-256 hash which can be used to verify the signature
Returns Uint8Array
getSenderAddress
Returns the sender's address
Returns Address
getSenderPublicKey
Returns the public key of the sender
Returns Uint8Array
getUpfrontCost
The up front amount that an account must have for this transaction to be valid
Parameters
optionalbaseFee: bigint
The base fee of the block (will be set to 0 if not provided)
Returns bigint
hash
Computes a sha3-256 hash of the serialized tx.
This method can only be used for signed txs (it throws otherwise). Use FeeMarketEIP1559Transaction.getMessageToSign to get a tx hash for the purpose of signing.
Returns Uint8Array
isSigned
Returns boolean
raw
Returns a Uint8Array Array of the raw Uint8Arrays of the EIP-1559 transaction, in order.
Format:
[chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
accessList, signatureYParity, signatureR, signatureS]Use FeeMarketEIP1559Transaction.serialize to add a transaction to a block with Block.fromValuesArray.
For an unsigned tx this method uses the empty Uint8Array values for the signature parameters
v
,r
ands
for encoding. For an EIP-155 compliant representation for external signing use FeeMarketEIP1559Transaction.getMessageToSign.Returns FeeMarketEIP1559ValuesArray
serialize
Returns the serialized encoding of the EIP-1559 transaction.
Format:
0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
accessList, signatureYParity, signatureR, signatureS])Note that in contrast to the legacy tx serialization format this is not valid RLP any more due to the raw tx type preceding and concatenated to the RLP encoding of the values.
Returns Uint8Array
sign
Signs a transaction.
Note that the signed tx is returned as a new object, use as follows:
const signedTx = tx.sign(privateKey)
Parameters
privateKey: Uint8Array
Returns FeeMarketEIP1559Transaction
supports
Checks if a tx type defining capability is active on a tx, for example the EIP-1559 fee market mechanism or the EIP-2930 access list feature.
Note that this is different from the tx type itself, so EIP-2930 access lists can very well be active on an EIP-1559 tx for example.
This method can be useful for feature checks if the tx type is unknown (e.g. when instantiated with the tx factory).
See
Capabilites
in thetypes
module for a reference on all supported capabilities.Parameters
capability: Capability
Returns boolean
toCreationAddress
If the tx's
to
is to the creation addressReturns boolean
toJSON
Returns an object with the JSON representation of the transaction
Returns JsonTx
validate
Checks if the transaction has the minimum amount of gas required (DataFee + TxFee + Creation Fee).
Returns boolean
verifySignature
Determines if the signature is valid
Returns boolean
staticfromSerializedTx
Instantiate a transaction from the serialized tx.
Format:
0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
accessList, signatureYParity, signatureR, signatureS])Parameters
serialized: Uint8Array
optionalopts: TxOptions
Returns FeeMarketEIP1559Transaction
staticfromTxData
Instantiate a transaction from a data dictionary.
Format: { chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, v, r, s }
Notes:
chainId
will be set automatically if not provided- All parameters are optional and have some basic default values
Parameters
txData: FeeMarketEIP1559TxData
optionalopts: TxOptions
Returns FeeMarketEIP1559Transaction
staticfromValuesArray
Create a transaction from a values array.
Format:
[chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
accessList, signatureYParity, signatureR, signatureS]Parameters
values: FeeMarketEIP1559ValuesArray
optionalopts: TxOptions
Returns FeeMarketEIP1559Transaction
Transaction
An Ethereum non-typed (legacy) transaction
constructor
This constructor takes the values, validates them, assigns them and freezes the object.
It is not recommended to use this constructor directly. Instead use the static factory methods to assist in creating a Transaction object from varying data types.
Parameters
txData: TxData
optionalopts: TxOptions
Returns Transaction
readonlycommon
readonlydata
readonlygasLimit
readonlygasPrice
readonlynonce
optionalreadonlyr
optionalreadonlys
optionalreadonlyto
optionalreadonlyv
readonlyvalue
type
Returns the transaction type.
Note: legacy txs will return tx type
0
.Returns number
errorStr
Return a compact error string representation of the object
Returns string
getBaseFee
The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
Returns bigint
getDataFee
The amount of gas paid for the data in this tx
Returns bigint
getMessageToSign
Returns the unsigned tx (hashed or raw), which can be used to sign the transaction (e.g. for sending to a hardware wallet).
Note: the raw message message format for the legacy tx is not RLP encoded and you might need to do yourself with:
import { bufArrToArr } from '../util'
import { RLP } from '../rlp'
const message = tx.getMessageToSign(false)
const serializedMessage = RLP.encode(message) // use this for the HW wallet inputParameters
hashMessage: false
Return hashed message if set to true (default: true)
Returns Uint8Array[]
getMessageToVerifySignature
Computes a sha3-256 hash which can be used to verify the signature
Returns Uint8Array
getSenderAddress
Returns the sender's address
Returns Address
getSenderPublicKey
Returns the public key of the sender
Returns Uint8Array
getUpfrontCost
The up front amount that an account must have for this transaction to be valid
Returns bigint
hash
Computes a sha3-256 hash of the serialized tx.
This method can only be used for signed txs (it throws otherwise). Use Transaction.getMessageToSign to get a tx hash for the purpose of signing.
Returns Uint8Array
isSigned
Returns boolean
raw
Returns a Uint8Array Array of the raw Uint8Arrays of the legacy transaction, in order.
Format:
[nonce, gasPrice, gasLimit, to, value, data, v, r, s]
For legacy txs this is also the correct format to add transactions to a block with Block.fromValuesArray (use the
serialize()
method for typed txs).For an unsigned tx this method returns the empty Uint8Array values for the signature parameters
v
,r
ands
. For an EIP-155 compliant representation have a look at Transaction.getMessageToSign.Returns TxValuesArray
serialize
Returns the serialized encoding of the legacy transaction.
Format:
rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])
For an unsigned tx this method uses the empty Uint8Array values for the signature parameters
v
,r
ands
for encoding. For an EIP-155 compliant representation for external signing use Transaction.getMessageToSign.Returns Uint8Array
sign
Signs a transaction.
Note that the signed tx is returned as a new object, use as follows:
const signedTx = tx.sign(privateKey)
Parameters
privateKey: Uint8Array
Returns Transaction
supports
Checks if a tx type defining capability is active on a tx, for example the EIP-1559 fee market mechanism or the EIP-2930 access list feature.
Note that this is different from the tx type itself, so EIP-2930 access lists can very well be active on an EIP-1559 tx for example.
This method can be useful for feature checks if the tx type is unknown (e.g. when instantiated with the tx factory).
See
Capabilites
in thetypes
module for a reference on all supported capabilities.Parameters
capability: Capability
Returns boolean
toCreationAddress
If the tx's
to
is to the creation addressReturns boolean
toJSON
Returns an object with the JSON representation of the transaction.
Returns JsonTx
validate
Checks if the transaction has the minimum amount of gas required (DataFee + TxFee + Creation Fee).
Returns boolean
verifySignature
Determines if the signature is valid
Returns boolean
staticfromSerializedTx
Instantiate a transaction from the serialized tx.
Format:
rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])
Parameters
serialized: Uint8Array
optionalopts: TxOptions
Returns Transaction
staticfromTxData
Instantiate a transaction from a data dictionary.
Format: { nonce, gasPrice, gasLimit, to, value, data, v, r, s }
Notes:
- All parameters are optional and have some basic default values
Parameters
txData: TxData
optionalopts: TxOptions
Returns Transaction
staticfromValuesArray
Create a transaction from a values array.
Format:
[nonce, gasPrice, gasLimit, to, value, data, v, r, s]
Parameters
values: TxValuesArray
optionalopts: TxOptions
Returns Transaction
TransactionFactory
staticfromBlockBodyData
When decoding a BlockBody, in the transactions field, a field is either: A Uint8Array (a TypedTransaction - encoded as TransactionType || rlp(TransactionPayload)) A Uint8Array[] (Legacy Transaction) This method returns the right transaction.
Parameters
data: Uint8Array | Uint8Array[]
A Uint8Array or Uint8Array[]
optionaltxOptions: TxOptions
The transaction options
Returns TypedTransaction
staticfromSerializedData
This method tries to decode serialized data.
Parameters
data: Uint8Array
The data Uint8Array
optionaltxOptions: TxOptions
The transaction options
Returns TypedTransaction
staticfromTxData
Create a transaction from a
txData
objectParameters
txData: TxData | TypedTransaction
The transaction data. The
type
field will determine which transaction type is returned (if undefined, creates a legacy transaction)optionaltxOptions: TxOptions
Options to pass on to the constructor of the transaction
Returns TypedTransaction
staticregisterTransactionType
Type parameters
- NewTxTypeClass: { prototype: BaseTransaction<any>; fromSerializedTx: any; fromTxData: any }
Parameters
type: Numbers
txClass: NewTxTypeClass
Returns void
statictypeToInt
Parameters
txType: Numbers
Returns number
Wallet
Wallet is an in memory wallet
that can hold multiple accounts.
These accounts can be used when using web3.eth.sendTransaction() or web3.eth.contract.methods.contractfunction().send();
For using Wallet functionality, install Web3 package using npm i web3
or yarn add web3
.
After that, Wallet functionality will be available as mentioned below.
import { Web3 } from 'web3';
const web3 = new Web3('http://127.0.0.1:7545');
const wallet = await web3.eth.accounts.wallet.create(2);
const signature = wallet.at(0).sign("Test Data"); // use wallet
// fund account before sending following transaction ...
const receipt = await web3.eth.sendTransaction({ // internally sign transaction using wallet
from: wallet.at(0).address,
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
value: 1
//....
});
Type parameters
constructor
Type parameters
Parameters
accountProvider: Web3AccountProvider<T>
Returns Wallet<T>
add
Adds an account using a private key or account object to the wallet.
Parameters
account: string | T
A private key or account object
Returns this
The wallet
web3.eth.accounts.wallet.add('0xbce9b59981303e76c4878b1a6d7b088ec6b9dd5c966b7d5f54d7a749ff683387');
> Wallet(1) [
{
address: '0x85D70633b90e03e0276B98880286D0D055685ed7',
privateKey: '0xbce9b59981303e76c4878b1a6d7b088ec6b9dd5c966b7d5f54d7a749ff683387',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
},
_accountProvider: {
create: [Function: create],
privateKeyToAccount: [Function: privateKeyToAccount],
decrypt: [Function: decrypt]
},
_addressMap: Map(1) { '0x85d70633b90e03e0276b98880286d0d055685ed7' => 0 },
_defaultKeyName: 'web3js_wallet'
]
clear
Securely empties the wallet and removes all its accounts. Use this with *caution as it will remove all accounts stored in local wallet.
Returns this
The wallet object
web3.eth.accounts.wallet.clear();
> Wallet(0) [
_accountProvider: {
create: [Function: create],
privateKeyToAccount: [Function: privateKeyToAccount],
decrypt: [Function: decrypt]
},
_addressMap: Map(0) {},
_defaultKeyName: 'web3js_wallet'
]
create
Generates one or more accounts in the wallet. If wallets already exist they will not be overridden.
Parameters
numberOfAccounts: number
Number of accounts to create. Leave empty to create an empty wallet.
Returns this
The wallet
web3.eth.accounts.wallet.create(2)
> Wallet(2) [
{
address: '0xde38310a42B751AE57d30cFFF4a0A3c52A442fCE',
privateKey: '0x6422c9d28efdcbee93c1d32a5fc6fd6fa081b985487885296cf8c9bbb5872600',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
},
{
address: '0x766BF755246d924B1d017Fdb5390f38a60166691',
privateKey: '0x756530f13c0eb636ebdda655335f5dea9921e3362e2e588b0ad59e556f7751f0',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
},
_accountProvider: {
create: [Function: create],
privateKeyToAccount: [Function: privateKeyToAccount],
decrypt: [Function: decrypt]
},
_addressMap: Map(2) {
'0xde38310a42b751ae57d30cfff4a0a3c52a442fce' => 0,
'0x766bf755246d924b1d017fdb5390f38a60166691' => 1
},
_defaultKeyName: 'web3js_wallet'
]
decrypt
Decrypts keystore v3 objects.
Parameters
encryptedWallets: KeyStore[]
An array of encrypted keystore v3 objects to decrypt
password: string
The password to encrypt with
optionaloptions: Record<string, unknown>
decrypt options for the wallets
Returns Promise<Wallet<T>>
The decrypted wallet object
web3.eth.accounts.wallet.decrypt([
{ version: 3,
id: '83191a81-aaca-451f-b63d-0c5f3b849289',
address: '06f702337909c06c82b09b7a22f0a2f0855d1f68',
crypto:
{ ciphertext: '7d34deae112841fba86e3e6cf08f5398dda323a8e4d29332621534e2c4069e8d',
cipherparams: { iv: '497f4d26997a84d570778eae874b2333' },
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams:
{ dklen: 32,
salt: '208dd732a27aa4803bb760228dff18515d5313fd085bbce60594a3919ae2d88d',
n: 262144,
r: 8,
p: 1 },
mac: '0062a853de302513c57bfe3108ab493733034bf3cb313326f42cf26ea2619cf9' } },
{ version: 3,
id: '7d6b91fa-3611-407b-b16b-396efb28f97e',
address: 'b5d89661b59a9af0b34f58d19138baa2de48baaf',
crypto:
{ ciphertext: 'cb9712d1982ff89f571fa5dbef447f14b7e5f142232bd2a913aac833730eeb43',
cipherparams: { iv: '8cccb91cb84e435437f7282ec2ffd2db' },
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams:
{ dklen: 32,
salt: '08ba6736363c5586434cd5b895e6fe41ea7db4785bd9b901dedce77a1514e8b8',
n: 262144,
r: 8,
p: 1 },
mac: 'd2eb068b37e2df55f56fa97a2bf4f55e072bef0dd703bfd917717d9dc54510f0' } }
], 'test').then(console.log)
> Wallet {
_accountProvider: {
create: [Function: create],
privateKeyToAccount: [Function: privateKeyToAccount],
decrypt: [Function: decrypt]
},
_defaultKeyName: 'web3js_wallet',
_accounts: {
'0x85d70633b90e03e0276b98880286d0d055685ed7': {
address: '0x85D70633b90e03e0276B98880286D0D055685ed7',
privateKey: '0xbce9b59981303e76c4878b1a6d7b088ec6b9dd5c966b7d5f54d7a749ff683387',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
},
'0x06f702337909c06c82b09b7a22f0a2f0855d1f68': {
address: '0x06F702337909C06C82B09B7A22F0a2f0855d1F68',
privateKey: '87a51da18900da7398b3bab03996833138f269f8f66dd1237b98df6b9ce14573',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
},
'0xb5d89661b59a9af0b34f58d19138baa2de48baaf': {
address: '0xB5d89661B59a9aF0b34f58D19138bAa2de48BAaf',
privateKey: '7ee61c5282979aae9dd795bb6a54e8bdc2bfe009acb64eb9a67322eec3b3da6e',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}
}
}
encrypt
Encrypts all wallet accounts to an array of encrypted keystore v3 objects.
Parameters
password: string
The password which will be used for encryption
optionaloptions: Record<string, unknown>
encryption options
Returns Promise<KeyStore[]>
An array of the encrypted keystore v3.
web3.eth.accounts.wallet.create(1)
web3.eth.accounts.wallet.encrypt("abc").then(console.log);
> [
'{"version":3,"id":"fa46e213-a7c3-4844-b903-dd14d39cc7db",
"address":"fa3e41a401609103c241431cbdee8623ae2a321a","crypto":
{"ciphertext":"8d179a911d6146ad2924e86bf493ed89b8ff3596ffec0816e761c542016ab13c",
"cipherparams":{"iv":"acc888c6cf4a19b86846cef0185a7164"},"cipher":"aes-128-ctr",
"kdf":"scrypt","kdfparams":{"n":8192,"r":8,"p":1,"dklen":32,"salt":"6a743c9b367d15f4758e4f3f3378ff0fd443708d1c64854e07588ea5331823ae"},
"mac":"410544c8307e3691fda305eb3722d82c3431f212a87daa119a21587d96698b57"}}'
]
get
Get the account of the wallet with either the index or public address.
Parameters
addressOrIndex: string | number
A string of the address or number index within the wallet.
Returns undefined | T
The account object or undefined if the account doesn't exist
load
Loads a wallet from local storage and decrypts it. NOTE: Browser only
Parameters
password: string
The password to decrypt the wallet.
optionalkeyName: string
(optional)The key used for local storage position, defaults to
web3js_wallet"
Returns Promise<Wallet<T>>
Returns the wallet object
web3.eth.accounts.wallet.save('test#!$');
> true
web3.eth.accounts.wallet.load('test#!$');
{ defaultKeyName: "web3js_wallet",
length: 0,
_accounts: Accounts {_requestManager: RequestManager, givenProvider: Proxy, providers: {…}, _provider: WebsocketProvider, …},
[[Prototype]]: Object
}
remove
Removes an account from the wallet.
Parameters
addressOrIndex: string | number
The account address, or index in the wallet.
Returns boolean
true if the wallet was removed. false if it couldn't be found.
web3.eth.accounts.wallet.add('0xbce9b59981303e76c4878b1a6d7b088ec6b9dd5c966b7d5f54d7a749ff683387');
web3.eth.accounts.wallet.remove('0x85D70633b90e03e0276B98880286D0D055685ed7');
> true
web3.eth.accounts.wallet
> Wallet(0) [
_accountProvider: {
create: [Function: create],
privateKeyToAccount: [Function: privateKeyToAccount],
decrypt: [Function: decrypt]
},
_addressMap: Map(0) {},
_defaultKeyName: 'web3js_wallet'
]
save
Stores the wallet encrypted and as string in local storage. NOTE: Browser only
Parameters
password: string
The password to encrypt the wallet
optionalkeyName: string
(optional) The key used for the local storage position, defaults to
"web3js_wallet"
.
Returns Promise<boolean>
Will return boolean value true if saved properly
web3.eth.accounts.wallet.save('test#!$');
>true
staticgetStorage
Get the storage object of the browser
Returns undefined | WebStorage
the storage
AccessListEIP2930TxData
AccessListEIP2930Transaction data.
optionalaccessList
The access list which contains the addresses/storage slots which the transaction wishes to access
optionalchainId
The transaction's chain ID
optionaldata
This will contain the data of the message or the init of a contract.
optionalgasLimit
The transaction's gas limit.
optionalgasPrice
The transaction's gas price.
optionalnonce
The transaction's nonce.
optionalr
EC signature parameter.
optionals
EC signature parameter.
optionalto
The transaction's the address is sent to.
optionaltype
The transaction type
optionalv
EC recovery ID.
optionalvalue
The amount of Ether sent.
BootstrapNodeConfig
optionalchainId
comment
id
ip
location
optionalnetwork
port
ChainConfig
optionalbootstrapNodes
chainId
optionalcomment
consensus
Type declaration
algorithm: string
optionalcasper?: CasperConfig
optionalclique?: CliqueConfig
optionalethash?: EthashConfig
type: string
optionaldefaultHardfork
optionaldnsNetworks
genesis
hardforks
name
networkId
optionalurl
ChainName
ChainsConfig
CommonOpts
Options for instantiating a Common instance.
chain
Chain name ('mainnet'), id (1), or Chain enum, either from a chain directly supported or a custom chain passed in via CommonOpts.customChains.
optionalcustomChains
Initialize (in addition to the supported chains) with the selected custom chains. Custom genesis state should be passed to the Blockchain class if used.
Usage (directly with the respective chain initialization via the CommonOpts.chain option):
import myCustomChain1 from '[PATH_TO_MY_CHAINS]/myCustomChain1.json'
const common = new Common({ chain: 'myCustomChain1', customChains: [ myCustomChain1 ]})
optionaleips
Selected EIPs which can be activated, please use an array for instantiation
(e.g. eips: [ 2537, ]
)
Currently supported:
- EIP-2537 - BLS12-381 precompiles
optionalhardfork
String identifier ('byzantium') for hardfork or Hardfork enum.
Default: Hardfork.London
CustomCommonOpts
Options to be used with the Common.custom static constructor.
optionalbaseChain
The name (mainnet
), id (1
), or Chain enum of
a standard chain used to base the custom chain params on.
optionaleips
Selected EIPs which can be activated, please use an array for instantiation
(e.g. eips: [ 2537, ]
)
Currently supported:
- EIP-2537 - BLS12-381 precompiles
optionalhardfork
String identifier ('byzantium') for hardfork or Hardfork enum.
Default: Hardfork.London
ECDSASignature
r
s
v
FeeMarketEIP1559TxData
FeeMarketEIP1559Transaction data.
optionalaccessList
The access list which contains the addresses/storage slots which the transaction wishes to access
optionalchainId
The transaction's chain ID
optionaldata
This will contain the data of the message or the init of a contract.
optionalgasLimit
The transaction's gas limit.
optionalgasPrice
The transaction's gas price, inherited from Transaction. This property is not used for EIP1559 transactions and should always be undefined for this specific transaction type.
optionalmaxFeePerGas
The maximum total fee
optionalmaxPriorityFeePerGas
The maximum inclusion fee per gas (this fee is given to the miner)
optionalnonce
The transaction's nonce.
optionalr
EC signature parameter.
optionals
EC signature parameter.
optionalto
The transaction's the address is sent to.
optionaltype
The transaction type
optionalv
EC recovery ID.
optionalvalue
The amount of Ether sent.
GenesisBlockConfig
optionalbaseFeePerGas
difficulty
extraData
gasLimit
nonce
optionaltimestamp
GethConfigOpts
optionalchain
optionaleips
Selected EIPs which can be activated, please use an array for instantiation
(e.g. eips: [ 2537, ]
)
Currently supported:
- EIP-2537 - BLS12-381 precompiles
optionalgenesisHash
optionalhardfork
String identifier ('byzantium') for hardfork or Hardfork enum.
Default: Hardfork.London
optionalmergeForkIdPostMerge
HardforkConfig
block
optionalforkHash
name
optionaltimestamp
optionalttd
JsonTx
Generic interface for all tx types with a JSON representation of a transaction.
Note that all values are marked as optional
and not all the values are present on all tx types
(an EIP1559 tx e.g. lacks a gasPrice
).
optionalaccessList
optionalchainId
optionaldata
optionalgasLimit
optionalgasPrice
optionalmaxFeePerDataGas
optionalmaxFeePerGas
optionalmaxPriorityFeePerGas
optionalnonce
optionalr
optionals
optionalto
optionaltype
optionalv
optionalvalue
optionalversionedHashes
TransformableToArray
toArray
Returns Uint8Array
TxOptions
The options for initializing a Transaction.
optionalallowUnlimitedInitCodeSize
Allows unlimited contract code-size init while debugging. This (partially) disables EIP-3860. Gas cost for initcode size analysis will still be charged. Use with caution.
optionalcommon
A Common object defining the chain and hardfork for the transaction.
Object will be internally copied so that tx behavior don't incidentally change on future HF changes.
Default: Common object set to mainnet
and the default hardfork as defined in the Common class.
Current default hardfork: istanbul
optionalfreeze
A transaction object by default gets frozen along initialization. This gives you
strong additional security guarantees on the consistency of the tx parameters.
It also enables tx hash caching when the hash()
method is called multiple times.
If you need to deactivate the tx freeze - e.g. because you want to subclass tx and add additional properties - it is strongly encouraged that you do the freeze yourself within your code instead.
Default: true
Web3Account
address
readonlyencrypt
Type declaration
Parameters
password: string
optionaloptions: Record<string, unknown>
Returns Promise<KeyStore>
privateKey
readonlysign
Type declaration
Parameters
data: string | Record<string, unknown>
Returns SignResult
readonlysignTransaction
Type declaration
Parameters
tx: Transaction
Returns Promise<SignTransactionResult>
WebStorage
This Web Storage API interface provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.
readonlylength
Returns the number of key/value pairs.
clear
Removes all key/value pairs, if there are any.
Dispatches a storage event on Window objects holding an equivalent Storage object.
Returns void
getItem
Returns the current value associated with the given key, or null if the given key does not exist.
Parameters
key: string
Returns null | string
key
Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
Parameters
index: number
Returns null | string
removeItem
Removes the key/value pair with the given key, if a key/value pair with the given key exists.
Dispatches a storage event on Window objects holding an equivalent Storage object.
Parameters
key: string
Returns void
setItem
Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
Dispatches a storage event on Window objects holding an equivalent Storage object.
Parameters
key: string
value: string
Returns void
AccessList
AccessListEIP2930ValuesArray
Uint8Array values array for an AccessListEIP2930Transaction
AccessListItem
Type declaration
address: PrefixedHexString
storageKeys: PrefixedHexString[]
AccessListUint8Array
AccessListUint8ArrayItem
BigIntLike
CasperConfig
CliqueConfig
Type declaration
epoch: number
period: number
EthashConfig
FeeMarketEIP1559ValuesArray
Uint8Array values array for a FeeMarketEIP1559Transaction
NestedUint8Array
PrefixedHexString
SignResult
SignTransactionResult
SignatureObject
Type declaration
messageHash: string
r: string
s: string
v: string
ToBytesInputTypes
TxData
Legacy Transaction Data
Type declaration
optionaldata?: Uint8ArrayLike
This will contain the data of the message or the init of a contract.
optionalgasLimit?: Numbers | Uint8Array
The transaction's gas limit.
optionalgasPrice?: Numbers | Uint8Array | null
The transaction's gas price.
optionalnonce?: Numbers | Uint8Array
The transaction's nonce.
optionalr?: Numbers | Uint8Array
EC signature parameter.
optionals?: Numbers | Uint8Array
EC signature parameter.
optionalto?: Address | Uint8Array | HexString
The transaction's the address is sent to.
optionaltype?: Numbers
The transaction type
optionalv?: Numbers | Uint8Array
EC recovery ID.
optionalvalue?: Numbers | Uint8Array
The amount of Ether sent.
TxValuesArray
Uint8Array values array for a legacy Transaction
TypeOutputReturnType
Type declaration
0: number
1: bigint
2: Uint8Array
3: PrefixedHexString
TypedTransaction
Uint8ArrayLike
constkeyStoreSchema
Type declaration
properties: { address: { type: string }; crypto: { properties: { cipher: { type: string }; cipherparams: { type: string }; ciphertext: { type: string }; kdf: { type: string }; kdfparams: { type: string }; mac: { type: string }; salt: { type: string } }; required: string[]; type: string }; id: { type: string }; version: { type: string } }
address: { type: string }
type: string
crypto: { properties: { cipher: { type: string }; cipherparams: { type: string }; ciphertext: { type: string }; kdf: { type: string }; kdfparams: { type: string }; mac: { type: string }; salt: { type: string } }; required: string[]; type: string }
properties: { cipher: { type: string }; cipherparams: { type: string }; ciphertext: { type: string }; kdf: { type: string }; kdfparams: { type: string }; mac: { type: string }; salt: { type: string } }
cipher: { type: string }
type: string
cipherparams: { type: string }
type: string
ciphertext: { type: string }
type: string
kdf: { type: string }
type: string
kdfparams: { type: string }
type: string
mac: { type: string }
type: string
salt: { type: string }
type: string
required: string[]
type: string
id: { type: string }
type: string
version: { type: string }
type: string
required: string[]
type: string
assertIsUint8Array
Throws if input is not a Uint8Array
Parameters
input: unknown
value to check
Returns asserts input is Uint8Array
bigIntToHex
Converts a bigint to a
0x
prefixed hex stringParameters
num: bigint
Returns string
bigIntToUint8Array
Converts a bigint to a Uint8Array
Parameters
num: bigint
Returns Uint8Array
bigIntToUnpaddedUint8Array
Convert value from bigint to an unpadded Uint8Array (useful for RLP transport)
Parameters
value: bigint
value to convert
Returns Uint8Array
create
Generates and returns a Web3Account object that includes the private and public key For creation of private key, it uses an audited package ethereum-cryptography/secp256k1 that is cryptographically secure random number with certain characteristics. Read more: https://www.npmjs.com/package/ethereum-cryptography#secp256k1-curve
Returns Web3Account
A Web3Account object
web3.eth.accounts.create();
{
address: '0xbD504f977021b5E5DdccD8741A368b147B3B38bB',
privateKey: '0x964ced1c69ad27a311c432fdc0d8211e987595f7eb34ab405a5f16bdc9563ec5',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [AsyncFunction: encrypt]
}
decrypt
Decrypts a v3 keystore JSON, and creates the account.
Parameters
keystore: string | KeyStore
the encrypted Keystore object or string to decrypt
password: string | Uint8Array
The password that was used for encryption
optionalnonStrict: boolean
if true and given a json string, the keystore will be parsed as lowercase.
Returns Promise<Web3Account>
Returns the decrypted Web3Account object Decrypting scrypt
web3.eth.accounts.decrypt({
version: 3,
id: 'c0cb0a94-4702-4492-b6e6-eb2ac404344a',
address: 'cda9a91875fc35c8ac1320e098e584495d66e47c',
crypto: {
ciphertext: 'cb3e13e3281ff3861a3f0257fad4c9a51b0eb046f9c7821825c46b210f040b8f',
cipherparams: { iv: 'bfb43120ae00e9de110f8325143a2709' },
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams: {
n: 8192,
r: 8,
p: 1,
dklen: 32,
salt: '210d0ec956787d865358ac45716e6dd42e68d48e346d795746509523aeb477dd'
},
mac: 'efbf6d3409f37c0084a79d5fdf9a6f5d97d11447517ef1ea8374f51e581b7efd'
}
}, '123').then(console.log);
> {
address: '0xcdA9A91875fc35c8Ac1320E098e584495d66e47c',
privateKey: '67f476289210e3bef3c1c75e4de993ff0a00663df00def84e73aa7411eac18a6',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [AsyncFunction: encrypt]
}
ecrecover
ECDSA public key recovery from signature. NOTE: Accepts
v === 0 | v === 1
for EIP1559 transactionsParameters
msgHash: Uint8Array
v: bigint
r: Uint8Array
s: Uint8Array
optionalchainId: bigint
Returns Uint8Array
Recovered public key
encrypt
encrypt a private key with a password, returns a V3 JSON Keystore
Read more: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
Parameters
privateKey: Bytes
The private key to encrypt, 32 bytes.
password: string | Uint8Array
The password used for encryption.
optionaloptions: CipherOptions
Options to configure to encrypt the keystore either scrypt or pbkdf2
Returns Promise<KeyStore>
Returns a V3 JSON Keystore
Encrypt using scrypt options:
web3.eth.accounts.encrypt(
'0x67f476289210e3bef3c1c75e4de993ff0a00663df00def84e73aa7411eac18a6',
'123',
{
n: 8192,
iv: web3.utils.hexToBytes('0xbfb43120ae00e9de110f8325143a2709'),
salt: web3.utils.hexToBytes('0x210d0ec956787d865358ac45716e6dd42e68d48e346d795746509523aeb477dd'),
}).then(console.log)
> {
version: 3,
id: 'c0cb0a94-4702-4492-b6e6-eb2ac404344a',
address: 'cda9a91875fc35c8ac1320e098e584495d66e47c',
crypto: {
ciphertext: 'cb3e13e3281ff3861a3f0257fad4c9a51b0eb046f9c7821825c46b210f040b8f',
cipherparams: { iv: 'bfb43120ae00e9de110f8325143a2709' },
cipher: 'aes-128-ctr',
kdf: 'scrypt',
kdfparams: {
n: 8192,
r: 8,
p: 1,
dklen: 32,
salt: '210d0ec956787d865358ac45716e6dd42e68d48e346d795746509523aeb477dd'
},
mac: 'efbf6d3409f37c0084a79d5fdf9a6f5d97d11447517ef1ea8374f51e581b7efd'
}
}Encrypting using pbkdf2 options:
web3.eth.accounts.encrypt('0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709',
'123',
{
iv: 'bfb43120ae00e9de110f8325143a2709',
salt: '210d0ec956787d865358ac45716e6dd42e68d48e346d795746509523aeb477dd',
c: 262144,
kdf: 'pbkdf2',
}).then(console.log)
>
{
version: 3,
id: '77381417-0973-4e4b-b590-8eb3ace0fe2d',
address: 'b8ce9ab6943e0eced004cde8e3bbed6568b2fa01',
crypto: {
ciphertext: '76512156a34105fa6473ad040c666ae7b917d14c06543accc0d2dc28e6073b12',
cipherparams: { iv: 'bfb43120ae00e9de110f8325143a2709' },
cipher: 'aes-128-ctr',
kdf: 'pbkdf2',
kdfparams: {
dklen: 32,
salt: '210d0ec956787d865358ac45716e6dd42e68d48e346d795746509523aeb477dd',
c: 262144,
prf: 'hmac-sha256'
},
mac: '46eb4884e82dc43b5aa415faba53cc653b7038e9d61cc32fd643cf8c396189b7'
}
}
hashMessage
Hashes the given message. The data will be
UTF-8 HEX
decoded and enveloped as follows:"\x19Ethereum Signed Message:\n" + message.length + message
and hashed using keccak256.Parameters
message: string
A message to hash, if its HEX it will be UTF8 decoded.
optionalskipPrefix: boolean
(default: false) If true, the message will be not prefixed with "\x19Ethereum Signed Message:\n" + message.length
Returns string
The hashed message
web3.eth.accounts.hashMessage("Hello world")
> "0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede"
web3.eth.accounts.hashMessage(web3.utils.utf8ToHex("Hello world")) // Will be hex decoded in hashMessage
> "0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede"
web3.eth.accounts.hashMessage("Hello world", true)
> "0xed6c11b0b5b808960df26f5bfc471d04c1995b0ffd2055925ad1be28d6baadfd"
intToUint8Array
Converts an
Number
to aUint8Array
Parameters
i: number
Returns Uint8Array
isAccessList
Parameters
input: AccessListUint8Array | AccessList
Returns input is AccessList
isAccessListUint8Array
Parameters
input: AccessListUint8Array | AccessList
Returns input is AccessListUint8Array
padToEven
Pads a
String
to have an even lengthParameters
value: string
Returns string
output
parseAndValidatePrivateKey
Get the private key Uint8Array after the validation. Note: This function is not exported through main web3 package, so for using it directly import from accounts package.
Parameters
data: Bytes
Private key
optionalignoreLength: boolean
Optional, ignore length check during validation
Returns Uint8Array
The Uint8Array private key
parseAndValidatePrivateKey("0x08c673022000ece7964ea4db2d9369c50442b2869cbd8fc21baaca59e18f642c")
> Uint8Array(32) [
186, 26, 143, 168, 235, 179, 90, 75,
101, 63, 84, 221, 152, 150, 30, 203,
8, 113, 94, 226, 53, 213, 216, 5,
194, 159, 17, 53, 219, 97, 121, 248
]
parseGethGenesis
Parses a genesis.json exported from Geth into parameters for Common instance
Parameters
json: any
representing the Geth genesis file
optionalname: string
optional chain name
optionalmergeForkIdPostMerge: boolean
Returns { bootstrapNodes: never[]; chainId: number; consensus: { algorithm: string; clique: { epoch: any; period: any }; ethash?: undefined; type: string } | { algorithm: string; clique?: undefined; ethash: {}; type: string }; genesis: { baseFeePerGas: string; coinbase: string; difficulty: number; extraData: string; gasLimit: number; mixHash: string; nonce: string; timestamp: string }; hardfork: string | undefined; hardforks: ConfigHardfork[]; name: string; networkId: number }
parsed params
bootstrapNodes: never[]
chainId: number
consensus: { algorithm: string; clique: { epoch: any; period: any }; ethash?: undefined; type: string } | { algorithm: string; clique?: undefined; ethash: {}; type: string }
genesis: { baseFeePerGas: string; coinbase: string; difficulty: number; extraData: string; gasLimit: number; mixHash: string; nonce: string; timestamp: string }
baseFeePerGas: string
coinbase: string
difficulty: number
extraData: string
gasLimit: number
mixHash: string
nonce: string
timestamp: string
hardfork: string | undefined
hardforks: ConfigHardfork[]
name: string
networkId: number
privateKeyToAccount
Get an Account object from the privateKey
Parameters
privateKey: Bytes
String or Uint8Array of 32 bytes
optionalignoreLength: boolean
if true, will not error check length
Returns Web3Account
A Web3Account object
The
Web3Account.signTransaction
is not stateful if directly imported from accounts package and used. Network access is required to get the accountnonce
andchainId
to sign the transaction, so use Web3.eth.accounts.signTransaction for signing transactions.:
web3.eth.accounts.privateKeyToAccount("0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709");
> {
address: '0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01',
privateKey: '0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709',
sign,
signTransaction,
encrypt,
}
privateKeyToAddress
Get the ethereum Address from a private key
Parameters
privateKey: Bytes
String or Uint8Array of 32 bytes
Returns string
The Ethereum address
privateKeyToPublicKey
Get the public key from a private key
Parameters
privateKey: Bytes
String or Uint8Array of 32 bytes
isCompressed: boolean
if true, will generate a 33 byte compressed public key instead of a 65 byte public key
Returns string
The public key
recover
Recovers the Ethereum address which was used to sign the given data
Parameters
data: string | SignatureObject
Either a signed message, hash, or the signatureObject
optionalsignatureOrV: string
signature or V
optionalprefixedOrR: string | boolean
prefixed or R
optionals: string
S value in signature
optionalprefixed: boolean
(default: false) If the last parameter is true, the given message will NOT automatically be prefixed with
"\\x19Ethereum Signed Message:\\n" + message.length + message
, and assumed to be already prefixed and hashed.
Returns string
The Ethereum address used to sign this data
const data = 'Some data';
const sigObj = web3.eth.accounts.sign(data, '0xbe6383dad004f233317e46ddb46ad31b16064d14447a95cc1d8c8d4bc61c3728')
> {
message: 'Some data',
messageHash: '0x1da44b586eb0729ff70a73c326926f6ed5a25f5b056e7f47fbc6e58d86871655',
v: '0x1b',
r: '0xa8037a6116c176a25e6fc224947fde9e79a2deaa0dd8b67b366fbdfdbffc01f9',
s: '0x53e41351267b20d4a89ebfe9c8f03c04de9b345add4a52f15bd026b63c8fb150',
signature: '0xa8037a6116c176a25e6fc224947fde9e79a2deaa0dd8b67b366fbdfdbffc01f953e41351267b20d4a89ebfe9c8f03c04de9b345add4a52f15bd026b63c8fb1501b'
}
// now recover
web3.eth.accounts.recover(data, sigObj.v, sigObj.r, sigObj.s)
> 0xEB014f8c8B418Db6b45774c326A0E64C78914dC0
recoverTransaction
Recovers the Ethereum address which was used to sign the given RLP encoded transaction.
Parameters
rawTransaction: string
The hex string having RLP encoded transaction
Returns string
The Ethereum address used to sign this transaction
web3.eth.accounts.recoverTransaction('0xf869808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a0c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895a0727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68');
> "0x2c7536E3605D9C16a7a3D7b1898e529396a65c23"
setLengthLeft
Left Pads a
Uint8Array
with leading zeros till it haslength
bytes. Or it truncates the beginning if it exceeds.Parameters
msg: Uint8Array
the value to pad (Uint8Array)
length: number
the number of bytes the output should be
Returns Uint8Array
(Uint8Array)
sign
Signs arbitrary data with a given private key. :::info The value passed as the data parameter will be UTF-8 HEX decoded and wrapped as follows: "\x19Ethereum Signed Message:\n" + message.length + message :::
Parameters
data: string
The data to sign
privateKey: Bytes
The 32 byte private key to sign with
Returns SignResult
The signature Object containing the message, messageHash, signature r, s, v
web3.eth.accounts.sign('Some data', '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318')
> {
message: 'Some data',
messageHash: '0x1da44b586eb0729ff70a73c326926f6ed5a25f5b056e7f47fbc6e58d86871655',
v: '0x1c',
r: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd',
s: '0x6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a029',
signature: '0xb91467e570a6466aa9e9876cbcd013baba02900b8979d43fe208a4a4f339f5fd6007e74cd82e037b800186422fc2da167c747ef045e5d18a5f5d4300f8e1a0291c'
}
signMessageWithPrivateKey
Takes a hash of a message and a private key, signs the message using the SECP256k1 elliptic curve algorithm, and returns the signature components.
Parameters
hash: string
The hash of the message to be signed, represented as a hexadecimal string.
privateKey: Bytes
The private key used to sign the message, represented as a byte array.
Returns SignResult
- The signature Object containing the message, messageHash, signature r, s, v
signRaw
Signs raw data with a given private key without adding the Ethereum-specific prefix.
Parameters
data: string
The raw data to sign. If it's a hex string, it will be used as-is. Otherwise, it will be UTF-8 encoded.
privateKey: Bytes
The 32 byte private key to sign with
Returns SignResult
The signature Object containing the message, messageHash, signature r, s, v
web3.eth.accounts.signRaw('Some data', '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318')
> {
message: 'Some data',
messageHash: '0x43a26051362b8040b289abe93334a5e3662751aa691185ae9e9a2e1e0c169350',
v: '0x1b',
r: '0x93da7e2ddd6b2ff1f5af0c752f052ed0d7d5bff19257db547a69cd9a879b37d4',
s: '0x334485e42b33815fd2cf8a245a5393b282214060844a9681495df2257140e75c',
signature: '0x93da7e2ddd6b2ff1f5af0c752f052ed0d7d5bff19257db547a69cd9a879b37d4334485e42b33815fd2cf8a245a5393b282214060844a9681495df2257140e75c1b'
}
signTransaction
Signs an Ethereum transaction with a given private key.
Parameters
transaction: TypedTransaction
The transaction, must be a legacy, EIP2930 or EIP 1559 transaction type
privateKey: string
The private key to import. This is 32 bytes of random data.
Returns Promise<SignTransactionResult>
A signTransactionResult object that contains message hash, r, s, v, transaction hash and raw transaction.
This function is not stateful here. We need network access to get the account
nonce
andchainId
to sign the transaction. This function will rely on user to provide the full transaction to be signed. If you want to sign a partial transaction object Use Web3.eth.accounts.sign instead.Signing a legacy transaction
import {signTransaction, Transaction} from 'web3-eth-accounts';
signTransaction(new Transaction({
to: '0x118C2E5F57FD62C2B5b46a5ae9216F4FF4011a07',
value: '0x186A0',
gasLimit: '0x520812',
gasPrice: '0x09184e72a000',
data: '',
chainId: 1,
nonce: 0 }),
'0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318')
> {
messageHash: '0x28b7b75f7ba48d588a902c1ff4d5d13cc0ca9ac0aaa39562368146923fb853bf',
v: '0x25',
r: '0x601b0017b0e20dd0eeda4b895fbc1a9e8968990953482214f880bae593e71b5',
s: '0x690d984493560552e3ebdcc19a65b9c301ea9ddc82d3ab8cfde60485fd5722ce',
rawTransaction: '0xf869808609184e72a0008352081294118c2e5f57fd62c2b5b46a5ae9216f4ff4011a07830186a08025a00601b0017b0e20dd0eeda4b895fbc1a9e8968990953482214f880bae593e71b5a0690d984493560552e3ebdcc19a65b9c301ea9ddc82d3ab8cfde60485fd5722ce',
transactionHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'Signing an eip 1559 transaction
import {signTransaction, Transaction} from 'web3-eth-accounts';
signTransaction(new Transaction({
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
maxPriorityFeePerGas: '0x3B9ACA00',
maxFeePerGas: '0xB2D05E00',
gasLimit: '0x6A4012',
value: '0x186A0',
data: '',
chainId: 1,
nonce: 0}),
"0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318")
> {
messageHash: '0x5744f24d5f0aff6c70487c8e85adf07d8564e50b08558788f00479611d7bae5f',
v: '0x25',
r: '0x78a5a6b2876c3985f90f82073d18d57ac299b608cc76a4ba697b8bb085048347',
s: '0x9cfcb40cc7d505ed17ff2d3337b51b066648f10c6b7e746117de69b2eb6358d',
rawTransaction: '0xf8638080836a401294f0109fc8df283027b6285cc889f5aa624eac1f55830186a08025a078a5a6b2876c3985f90f82073d18d57ac299b608cc76a4ba697b8bb085048347a009cfcb40cc7d505ed17ff2d3337b51b066648f10c6b7e746117de69b2eb6358d',
transactionHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
}Signing an eip 2930 transaction
import {signTransaction, Transaction} from 'web3-eth-accounts';
signTransaction(new Transaction ({
chainId: 1,
nonce: 0,
gasPrice: '0x09184e72a000',
gasLimit: '0x2710321',
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
value: '0x186A0',
data: '',
accessList: [
{
address: '0x0000000000000000000000000000000000000101',
storageKeys: [
'0x0000000000000000000000000000000000000000000000000000000000000000',
'0x00000000000000000000000000000000000000000000000000000000000060a7',
],
},
],
}),"0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318")
> {
messageHash: '0xc55ea24bdb4c379550a7c9a6818ac39ca33e75bc78ddb862bd82c31cc1c7a073',
v: '0x26',
r: '0x27344e77871c8b2068bc998bf28e0b5f9920867a69c455b2ed0c1c150fec098e',
s: '0x519f0130a1d662841d4a28082e9c9bb0a15e0e59bb46cfc39a52f0e285dec6b9',
rawTransaction: '0xf86a808609184e72a000840271032194f0109fc8df283027b6285cc889f5aa624eac1f55830186a08026a027344e77871c8b2068bc998bf28e0b5f9920867a69c455b2ed0c1c150fec098ea0519f0130a1d662841d4a28082e9c9bb0a15e0e59bb46cfc39a52f0e285dec6b9',
transactionHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
}
stripHexPrefix
Removes '0x' from a given
String
if presentParameters
str: string
the string value
Returns string
the string without 0x prefix
stripZeros
Trims leading zeros from a
Uint8Array
,String
orNumber[]
.Type parameters
- T: string | Uint8Array | number[]
Parameters
a: T
(Uint8Array|Array|String)
Returns T
(Uint8Array|Array|String)
toType
Convert an input to a specified type. Input of null/undefined returns null/undefined regardless of the output type.
Type parameters
- T: TypeOutput
Parameters
input: null
value to convert
outputType: T
type to output
Returns null
toUint8Array
Attempts to turn a value into a
Uint8Array
. Inputs supported:Uint8Array
String
(hex-prefixed),Number
, null/undefined,BigInt
and other objects with atoArray()
ortoUint8Array()
method.Parameters
v: ToBytesInputTypes
the value
Returns Uint8Array
uint8ArrayToBigInt
Converts a Uint8Array to a bigint
Parameters
buf: Uint8Array
Returns bigint
unpadUint8Array
Trims leading zeros from a
Uint8Array
.Parameters
a: Uint8Array
(Uint8Array)
Returns Uint8Array
(Uint8Array)
zeros
Returns a Uint8Array filled with 0s.
Parameters
bytes: number
the number of bytes the Uint8Array should be
Returns Uint8Array
contract
Contract
ContractDeploySend
ContractMethodSend
default
ContractLogsSubscription
ContractLogsSubscription to be used to subscribe to events logs.
Following events are supported and can be accessed with either ContractLogsSubscription.once or $ContractLogsSubscription.on methods.
- connected: Emitted when the subscription is connected.
- data: Fires on each incoming event with the event object as argument.
- changed: Fires on each event which was removed from the blockchain. The event will have the additional property
removed: true
. - error: Fires on each error.
const subscription = await myContract.events.MyEvent({
filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
fromBlock: 0
});
subscription.on("connected", function(subscriptionId){
console.log(subscriptionId);
});
subscription.on('data', function(event){
console.log(event); // same results as the optional callback above
});
subscription.on('changed', function(event){
// remove event from local database
})
subscription.on('error', function(error, receipt) { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
...
});
// event output example
> {
returnValues: {
myIndexedParam: 20,
myOtherIndexedParam: '0x123456789...',
myNonIndexParam: 'My String'
},
raw: {
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
},
event: 'MyEvent',
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
logIndex: 0,
transactionIndex: 0,
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
blockNumber: 1234,
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
}
constructor
Parameters
args: { abi: AbiBaseFragment & { anonymous?: boolean; inputs?: readonly AbiParameter[]; name: string; type: string } & { signature: string }; address?: string; jsonInterface: ContractAbiWithSignature; topics?: (null | string | string[])[] }
abi: AbiBaseFragment & { anonymous?: boolean; inputs?: readonly AbiParameter[]; name: string; type: string } & { signature: string }
optionaladdress: string
jsonInterface: ContractAbiWithSignature
optionaltopics: (null | string | string[])[]
options: { returnFormat?: DataFormat; subscriptionManager: Web3SubscriptionManager<unknown, {}> }
optionalreturnFormat: DataFormat
subscriptionManager: Web3SubscriptionManager<unknown, {}>
Returns ContractLogsSubscription
readonlyabi
The JSON Interface of the event.
optionalreadonlyaddress
Address of tye contract
readonlyargs
Type declaration
abi: AbiEventFragment
optionaladdress?: string
optionaltopics?: (null | string | string[])[]
readonlyjsonInterface
optionalreadonlytopics
The list of topics subscribed
id
Returns undefined | string
lastBlock
Returns undefined | BlockOutput
_processSubscriptionError
Parameters
error: Error
Returns void
_processSubscriptionResult
Parameters
data: unknown
Returns void
emit
Type parameters
- K: Web3EventKey<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents>
Parameters
eventName: K
params: { changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents[K]
Returns void
eventNames
Returns (string | symbol)[]
getMaxListeners
Returns number
listenerCount
Type parameters
- K: Web3EventKey<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns number
listeners
Type parameters
- K: Web3EventKey<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns (...args: any[]) => void[]
off
Type parameters
- K: Web3EventKey<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents[K]>
Returns void
on
Type parameters
- K: Web3EventKey<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents[K]>
Returns void
once
Type parameters
- K: Web3EventKey<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ changed: EventLog & { removed: true }; data: EventLog } & CommonSubscriptionEvents[K]>
Returns void
processSubscriptionData
Parameters
Returns void
removeAllListeners
Returns EventEmitter
resubscribe
Returns Promise<void>
sendSubscriptionRequest
Returns Promise<string>
sendUnsubscribeRequest
Returns Promise<void>
setMaxListenerWarningThreshold
Parameters
maxListenersWarningThreshold: number
Returns void
subscribe
Returns Promise<string>
unsubscribe
Returns Promise<void>
DeployerMethodClass
Type parameters
- FullContractAbi: ContractAbi
constructor
Type parameters
- FullContractAbi: ContractAbi
Parameters
parent: Contract<FullContractAbi>
deployOptions: undefined | { arguments?: ContractConstructorArgs<FullContractAbi>; data?: string; input?: string }
optionalarguments: ContractConstructorArgs<FullContractAbi>
The arguments which get passed to the constructor on deployment.
optionaldata: string
The byte code of the contract.
optionalinput: string
Returns DeployerMethodClass<FullContractAbi>
deployOptions
parent
decodeData
Parameters
data: string
Returns { __length__: number; __method__: string }
__length__: number
__method__: string
encodeABI
Returns string
estimateGas
Type parameters
- ReturnFormat: DataFormat = { bytes: HEX; number: BIGINT }
Parameters
optionaloptions: PayableCallOptions
optionalreturnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
populateTransaction
Parameters
optionaltxOptions: PayableCallOptions | NonPayableCallOptions
Returns TransactionCall
send
Parameters
optionaloptions: PayableCallOptions
Returns ContractDeploySend<FullContractAbi>
ContractEventOptions
optionalfilter
Let you filter events by indexed parameters, e.g. {filter: {myNumber: [12,13]}}
means all events where myNumber
is 12
or 13
.
optionalfromBlock
The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as earliest
, latest
, pending
, safe
or finalized
can also be used. For specific range use Contract.getPastEvents.
optionaltopics
This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as or
operation between the given nested topics.
ContractOptions
Represents the options for a contract.
optionaladdress
The address used for this contract instance. All transactions generated by web3.js from this contract will contain this address as the to
.
The address will be stored in lowercase.
optionalreadonlydata
The byte code of the contract. Used when the contract gets deployed
optionalreadonlyfrom
The address transactions should be made from.
optionalreadonlygas
The maximum gas provided for a transaction (gas limit).
optionalreadonlygasPrice
The gas price in wei to use for transactions.
optionalreadonlyinput
The byte code of the contract. Used when the contract gets deployed
optionalmaxFeePerGas
The max fee per gas to use for transactions.
optionalmaxPriorityFeePerGas
The max priority fee per gas to use for transactions.
jsonInterface
The json interface object derived from the ABI of this contract.
Re-setting this will regenerate the methods and events of the contract instance.
Returns ContractAbiWithSignature
Parameters
value: ContractAbi
Returns void
EventLog
readonlyaddress
optionalreadonlyblockHash
optionalreadonlyblockNumber
readonlydata
readonlyevent
optionalreadonlyid
optionalreadonlylogIndex
optionalreadonlyraw
Type declaration
data: string
topics: unknown[]
readonlyreturnValues
optionalreadonlysignature
readonlytopics
optionalreadonlytransactionHash
optionalreadonlytransactionIndex
NonPayableMethodObject
Type parameters
- Inputs = unknown[]
- Outputs = unknown[]
arguments
call
This will call a method and execute its smart contract method in the EVM without sending any transaction. Note calling cannot alter the smart contract state.
// using the promise
const result = await myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
// MULTI-ARGUMENT RETURN:
// Solidity
contract MyContract {
function myFunction() returns(uint256 myNumber, string myString) {
return (23456, "Hello!%");
}
}
// web3.js
var MyContract = new web3.eth.Contract(abi, address);
const result = MyContract.methods.myFunction().call()
console.log(result)
> Result {
myNumber: '23456',
myString: 'Hello!%',
0: '23456', // these are here as fallbacks if the name is not know or given
1: 'Hello!%'
}
// SINGLE-ARGUMENT RETURN:
// Solidity
contract MyContract {
function myFunction() returns(string myString) {
return "Hello!%";
}
}
// web3.js
const MyContract = new web3.eth.Contract(abi, address);
const result = await MyContract.methods.myFunction().call();
console.log(result);
> "Hello!%"Type parameters
- SpecialOutput = Outputs
Parameters
optionaltx: NonPayableCallOptions
The options used for calling.
optionalblock: BlockNumberOrTag
If you pass this parameter it will not use the default block set with contract.defaultBlock. Pre-defined block numbers as
earliest
,latest
,pending
,safe
or `finalized can also be used. Useful for requesting data from or replaying transactions in past blocks.
Returns Promise<SpecialOutput>
- The return value(s) of the smart contract method. If it returns a single value, it’s returned as is. If it has multiple return values they are returned as an object with properties and indices.
createAccessList
This method generates an access list for a transaction. You must specify a
from
address andgas
if it’s not specified in options.Parameters
optionaltx: NonPayableCallOptions
optionalblock: BlockNumberOrTag
If you pass this parameter it will not use the default block set with contract.defaultBlock. Pre-defined block numbers as
earliest
,latest
,pending
,safe
or `finalized can also be used. Useful for requesting data from or replaying transactions in past blocks.
Returns Promise<AccessListResult>
The returned data of the createAccessList, e.g. The generated access list for transaction.
const result = await MyContract.methods.myFunction().createAccessList();
console.log(result);
> {
"accessList": [
{
"address": "0x15859bdf5aff2080a9968f6a410361e9598df62f",
"storageKeys": [
"0x0000000000000000000000000000000000000000000000000000000000000000"
]
}
],
"gasUsed": "0x7671"
}
decodeData
Decode raw result of method call into readable value(s).
Type parameters
- SpecialInputs = Inputs
Parameters
data: string
The data to decode.
Returns SpecialInputs
- The decoded data.
encodeABI
Encodes the ABI for this method. The resulting hex string is 32-bit function signature hash plus the passed parameters in Solidity tightly packed format. This can be used to send a transaction, call a method, or pass it into another smart contract’s method as arguments. Set the data field on
web3.eth.sendTransaction
options as the encodeABI() result and it is the same as calling the contract method withcontract.myMethod.send()
.Some use cases for encodeABI() include: preparing a smart contract transaction for a multi signature wallet, working with offline wallets and cold storage and creating transaction payload for complex smart contract proxy calls.
Returns string
- The encoded ABI byte code to send via a transaction or call.
estimateGas
Returns the amount of gas consumed by executing the method locally without creating a new transaction on the blockchain. The returned amount can be used as a gas estimate for executing the transaction publicly. The actual gas used can be different when sending the transaction later, as the state of the smart contract can be different at that time.
const gasAmount = await myContract.methods.myMethod(123).estimateGas({gas: 5000000});
if(gasAmount == 5000000) {
console.log('Method ran out of gas');
}Type parameters
- ReturnFormat: DataFormat = { bytes: HEX; number: BIGINT }
Parameters
optionaloptions: NonPayableCallOptions
The options used for calling
optionalreturnFormat: ReturnFormat
The data format you want the output in.
Returns Promise<NumberTypes[ReturnFormat[number]]>
- The gas amount estimated.
populateTransaction
Parameters
optionaltx: PayableCallOptions | NonPayableCallOptions
optionalcontractOptions: ContractOptions
Returns TransactionCall
send
This will send a transaction to the smart contract and execute its method. Note this can alter the smart contract state.
await myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
const receipt = await myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
// using the event emitter
const sendObj = myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
sendObj.on('transactionHash', function(hash){
...
});
sendObj.on('confirmation', function(confirmationNumber, receipt){
...
});
sendObj.on('receipt', function(receipt){
// receipt example
console.log(receipt);
> {
"transactionHash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
"transactionIndex": 0,
"blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
"blockNumber": 3,
"contractAddress": "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe",
"cumulativeGasUsed": 314159,
"gasUsed": 30234,
"events": {
"MyEvent": {
returnValues: {
myIndexedParam: 20,
myOtherIndexedParam: '0x123456789...',
myNonIndexParam: 'My String'
},
raw: {
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
},
event: 'MyEvent',
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
logIndex: 0,
transactionIndex: 0,
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
blockNumber: 1234,
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
},
"MyOtherEvent": {
...
},
"MyMultipleEvent":[{...}, {...}] // If there are multiple of the same event, they will be in an array
}
}
});
sendObj.on('error', function(error, receipt) { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
...
});Parameters
optionaltx: NonPayableCallOptions
The options used for sending.
Returns Web3PromiEvent<{ blockHash: string; blockNumber: bigint; contractAddress?: string; cumulativeGasUsed: bigint; effectiveGasPrice?: bigint; events?: {}; from: string; gasUsed: bigint; logs: { address?: string; blockHash?: string; blockNumber?: bigint; data?: string; id?: string; logIndex?: bigint; removed?: boolean; topics?: string[]; transactionHash?: string; transactionIndex?: bigint }[]; logsBloom: string; root: string; status: bigint; to: string; transactionHash: string; transactionIndex: bigint; type?: bigint }, SendTransactionEvents<{ bytes: HEX; number: BIGINT }>>
- Returns a PromiEvent resolved with transaction receipt.
PayableMethodObject
Type parameters
- Inputs = unknown[]
- Outputs = unknown[]
arguments
call
Will call a method and execute its smart contract method in the EVM without sending any transaction. Note calling cannot alter the smart contract state.
// using the promise
const result = await myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
// MULTI-ARGUMENT RETURN:
// Solidity
contract MyContract {
function myFunction() returns(uint256 myNumber, string myString) {
return (23456, "Hello!%");
}
}
// web3.js
var MyContract = new web3.eth.Contract(abi, address);
const result = MyContract.methods.myFunction().call()
console.log(result)
> Result {
myNumber: '23456',
myString: 'Hello!%',
0: '23456', // these are here as fallbacks if the name is not know or given
1: 'Hello!%'
}
// SINGLE-ARGUMENT RETURN:
// Solidity
contract MyContract {
function myFunction() returns(string myString) {
return "Hello!%";
}
}
// web3.js
const MyContract = new web3.eth.Contract(abi, address);
const result = await MyContract.methods.myFunction().call();
console.log(result);
> "Hello!%"Type parameters
- SpecialOutput = Outputs
Parameters
optionaltx: PayableCallOptions
The options used for calling.
optionalblock: BlockNumberOrTag
If you pass this parameter it will not use the default block set with contract.defaultBlock. Pre-defined block numbers as
earliest
,latest
,pending
,safe
or `finalized can also be used. Useful for requesting data from or replaying transactions in past blocks.
Returns Promise<SpecialOutput>
- The return value(s) of the smart contract method. If it returns a single value, it’s returned as is. If it has multiple return values they are returned as an object with properties and indices.
createAccessList
This method generates an access list for a transaction. You must specify a
from
address andgas
if it’s not specified in options.Parameters
optionaltx: PayableCallOptions
optionalblock: BlockNumberOrTag
If you pass this parameter it will not use the default block set with contract.defaultBlock. Pre-defined block numbers as
earliest
,latest
,pending
,safe
or `finalized can also be used. Useful for requesting data from or replaying transactions in past blocks.
Returns Promise<AccessListResult>
The returned data of the createAccessList, e.g. The generated access list for transaction.
const result = await MyContract.methods.myFunction().createAccessList();
console.log(result);
> {
"accessList": [
{
"address": "0x15859bdf5aff2080a9968f6a410361e9598df62f",
"storageKeys": [
"0x0000000000000000000000000000000000000000000000000000000000000000"
]
}
],
"gasUsed": "0x7671"
}
decodeData
Decode raw result of method call into readable value(s).
Type parameters
- SpecialInputs = Inputs
Parameters
data: string
The data to decode.
Returns SpecialInputs
- The decoded data.
encodeABI
Encodes the ABI for this method. The resulting hex string is 32-bit function signature hash plus the passed parameters in Solidity tightly packed format. This can be used to send a transaction, call a method, or pass it into another smart contract’s method as arguments. Set the data field on
web3.eth.sendTransaction
options as the encodeABI() result and it is the same as calling the contract method withcontract.myMethod.send()
.Some use cases for encodeABI() include: preparing a smart contract transaction for a multi signature wallet, working with offline wallets and cold storage and creating transaction payload for complex smart contract proxy calls.
Returns string
- The encoded ABI byte code to send via a transaction or call.
estimateGas
Returns the amount of gas consumed by executing the method locally without creating a new transaction on the blockchain. The returned amount can be used as a gas estimate for executing the transaction publicly. The actual gas used can be different when sending the transaction later, as the state of the smart contract can be different at that time.
const gasAmount = await myContract.methods.myMethod(123).estimateGas({gas: 5000000});
if(gasAmount == 5000000) {
console.log('Method ran out of gas');
}Type parameters
- ReturnFormat: DataFormat = { bytes: HEX; number: BIGINT }
Parameters
optionaloptions: PayableCallOptions
The options used for calling
optionalreturnFormat: ReturnFormat
The data format you want the output in.
Returns Promise<NumberTypes[ReturnFormat[number]]>
- The gas amount estimated.
populateTransaction
Parameters
optionaltx: PayableCallOptions | NonPayableCallOptions
optionalcontractOptions: ContractOptions
Returns TransactionCall
send
Will send a transaction to the smart contract and execute its method. Note this can alter the smart contract state.
await myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
const receipt = await myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'});
// using the event emitter
const sendObj = myContract.methods.myMethod(123).send({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'})
sendObj.on('transactionHash', function(hash){
...
});
sendObj.on('confirmation', function(confirmationNumber, receipt){
...
});
sendObj.on('receipt', function(receipt){
// receipt example
console.log(receipt);
> {
"transactionHash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
"transactionIndex": 0,
"blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
"blockNumber": 3,
"contractAddress": "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe",
"cumulativeGasUsed": 314159,
"gasUsed": 30234,
"events": {
"MyEvent": {
returnValues: {
myIndexedParam: 20,
myOtherIndexedParam: '0x123456789...',
myNonIndexParam: 'My String'
},
raw: {
data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
},
event: 'MyEvent',
signature: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
logIndex: 0,
transactionIndex: 0,
transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
blockNumber: 1234,
address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
},
"MyOtherEvent": {
...
},
"MyMultipleEvent":[{...}, {...}] // If there are multiple of the same event, they will be in an array
}
}
});
sendObj.on('error', function(error, receipt) { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
...
});Parameters
optionaltx: PayableCallOptions
The options used for sending.
Returns Web3PromiEvent<{ blockHash: string; blockNumber: bigint; contractAddress?: string; cumulativeGasUsed: bigint; effectiveGasPrice?: bigint; events?: {}; from: string; gasUsed: bigint; logs: { address?: string; blockHash?: string; blockNumber?: bigint; data?: string; id?: string; logIndex?: bigint; removed?: boolean; topics?: string[]; transactionHash?: string; transactionIndex?: bigint }[]; logsBloom: string; root: string; status: bigint; to: string; transactionHash: string; transactionIndex: bigint; type?: bigint }, SendTransactionEvents<{ bytes: HEX; number: BIGINT }>>
- Returns a PromiEvent object resolved with transaction receipt.
ContractAbiWithSignature
ContractEventEmitterInterface
Type parameters
- Abi: ContractAbi
ContractEventsInterface
Type parameters
- Abi: ContractAbi
- Events: ContractEvents<Abi> = ContractEvents<Abi>
ContractMethodsInterface
Type parameters
- Abi: ContractAbi
ContractOverloadedMethodInputs
Type parameters
- AbiArr: ReadonlyArray<unknown>
ContractOverloadedMethodOutputs
Type parameters
- AbiArr: ReadonlyArray<unknown>
LogsSubscription
NonPayableTxOptions
PayableTxOptions
Web3ContractContext
create2ContractAddress
Parameters
from: string
salt: string
initCode: string
Returns string
createContractAddress
Parameters
from: string
nonce: Numbers
Returns string
decodeEventABI
Parameters
event: AbiBaseFragment & { anonymous?: boolean; inputs?: readonly AbiParameter[]; name: string; type: string } & { signature: string }
data: LogsInput
jsonInterface: ContractAbiWithSignature
optionalreturnFormat: DataFormat
Returns EventLog
decodeMethodParams
Parameters
functionsAbi: AbiFunctionFragment | AbiConstructorFragment
data: string
optionalmethodSignatureProvided: boolean
Returns DecodedParams & { __method__: string }
decodeMethodReturn
Parameters
functionsAbi: AbiFunctionFragment
optionalreturnValues: string
Returns unknown
encodeEventABI
Parameters
__namedParameters: ContractOptions
event: AbiBaseFragment & { anonymous?: boolean; inputs?: readonly AbiParameter[]; name: string; type: string } & { signature: string }
optionaloptions: Filter
Returns Writeable<Filter>
encodeMethodABI
Parameters
abi: AbiFunctionFragment | AbiConstructorFragment
args: unknown[]
optionaldeployData: string
Returns string
getCreateAccessListParams
Parameters
__namedParameters: { abi: AbiFunctionFragment; contractOptions: ContractOptions; options?: (PayableCallOptions | NonPayableCallOptions) & { to?: string | undefined; dataInputFill?: "input" | "data" | "both" | undefined; }; params: unknown[] }
abi: AbiFunctionFragment
contractOptions: ContractOptions
optionaloptions: (PayableCallOptions | NonPayableCallOptions) & { to?: string | undefined; dataInputFill?: "input" | "data" | "both" | undefined; }
params: unknown[]
Returns TransactionForAccessList
getEstimateGasParams
Parameters
__namedParameters: { abi: AbiFunctionFragment; contractOptions: ContractOptions; options?: (PayableCallOptions | NonPayableCallOptions) & { dataInputFill?: "input" | "data" | "both" | undefined; }; params: unknown[] }
abi: AbiFunctionFragment
contractOptions: ContractOptions
optionaloptions: (PayableCallOptions | NonPayableCallOptions) & { dataInputFill?: "input" | "data" | "both" | undefined; }
params: unknown[]
Returns Partial<TransactionWithSenderAPI>
getEthTxCallParams
Parameters
__namedParameters: { abi: AbiFunctionFragment; contractOptions: ContractOptions; options?: (PayableCallOptions | NonPayableCallOptions) & { to?: string | undefined; dataInputFill?: "input" | "data" | "both" | undefined; }; params: unknown[] }
abi: AbiFunctionFragment
contractOptions: ContractOptions
optionaloptions: (PayableCallOptions | NonPayableCallOptions) & { to?: string | undefined; dataInputFill?: "input" | "data" | "both" | undefined; }
params: unknown[]
Returns TransactionCall
getSendTxParams
Parameters
__namedParameters: { abi: AbiFunctionFragment | AbiConstructorFragment; contractOptions: ContractOptions; options?: (PayableCallOptions | NonPayableCallOptions) & { input?: string | undefined; data?: string | undefined; to?: string | undefined; dataInputFill?: "input" | ... 2 more ... | undefined; }; params: unknown[] }
abi: AbiFunctionFragment | AbiConstructorFragment
contractOptions: ContractOptions
optionaloptions: (PayableCallOptions | NonPayableCallOptions) & { input?: string | undefined; data?: string | undefined; to?: string | undefined; dataInputFill?: "input" | ... 2 more ... | undefined; }
params: unknown[]
Returns TransactionCall
isWeb3ContractContext
Parameters
options: unknown
Returns options is Partial<Web3ContextInitOptions<EthExecutionAPI, { logs: typeof ContractLogsSubscription; newBlockHeaders: typeof NewHeadsSubscription; newHeads: typeof NewHeadsSubscription }>>
ens
ENS
This class is designed to interact with the ENS system on the Ethereum blockchain.
For using ENS package, first install Web3 package using: npm i web3
or yarn add web3
based on your package manager, after that ENS features can be used as mentioned in following snippet.
import { Web3 } from 'web3';
const web3 = new Web3('https://127.0.0.1:4545');
console.log(await web3.eth.ens.getAddress('ethereum.eth'))
For using individual package install web3-eth-ens
packages using: npm i web3-eth-ens
or yarn add web3-eth-ens
. This is more efficient approach for building lightweight applications.
import { ENS } from 'web3-eth-ens';
const ens = new ENS(undefined,'https://127.0.0.1:4545');
console.log(await ens.getAddress('vitalik.eth'));
constructor
Use to create an instance of ENS
Parameters
optionalregistryAddr: string
(Optional) The address of the ENS registry (default: mainnet registry address)
optionalprovider: string | SupportedProviders<EthExecutionAPI & Web3NetAPI> | Web3ContextObject<EthExecutionAPI & Web3NetAPI, any>
(Optional) The provider to use for the ENS instance
Returns ENS
config
readonlyproviders
Type declaration
HttpProvider: Web3BaseProviderConstructor
WebsocketProvider: Web3BaseProviderConstructor
registryAddress
The registryAddress property can be used to define a custom registry address when you are connected to an unknown chain. It defaults to the main registry address.
staticoptionalgivenProvider
staticreadonlyproviders
Type declaration
HttpProvider: Web3BaseProviderConstructor
WebsocketProvider: Web3BaseProviderConstructor
BatchRequest
Will return the Web3BatchRequest constructor.
Returns new () => Web3BatchRequest
Returns Web3BatchRequest
accountProvider
Returns undefined | Web3AccountProvider<Web3BaseWalletAccount>
blockHeaderTimeout
The blockHeaderTimeout is used over socket-based connections. This option defines the amount seconds it should wait for
'newBlockHeaders'
event before falling back to polling to fetch transaction receipt. Default is10
seconds.Returns number
Will set the blockHeaderTimeout
Parameters
val: number
Returns void
contractDataInputFill
The
contractDataInputFill
options property will allow you to set the hash of the method signature and encoded parameters to the property eitherdata
,input
or both within your contract. This will affect the contracts send, call and estimateGas methods Default isdata
.Returns input | data | both
Will set the contractDataInputFill
Parameters
val: input | data | both
Returns void
currentProvider
Will return the current provider. (The same as
provider
)Returns undefined | Web3BaseProvider<API>
Returns the current provider
Will set the current provider. (The same as
provider
)Parameters
provider: undefined | string | SupportedProviders<API>
SupportedProviders The provider to set
Returns void
customTransactionSchema
Returns undefined | CustomTransactionSchema
Parameters
schema: undefined | CustomTransactionSchema
Returns void
defaultAccount
This default address is used as the default
from
property, if nofrom
property is specified in for the following methods:- web3.eth.sendTransaction()
- web3.eth.call()
- myContract.methods.myMethod().call()
- myContract.methods.myMethod().send()
Returns undefined | string
Will set the default account.
Parameters
val: undefined | string
Returns void
defaultBlock
The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter. The default value is
"latest"
.- web3.eth.getBalance()
- web3.eth.getCode()
- web3.eth.getTransactionCount()
- web3.eth.getStorageAt()
- web3.eth.call()
- myContract.methods.myMethod().call()
Returns BlockNumberOrTag
Will set the default block.
- A block number
"earliest"
- String: The genesis block"latest"
- String: The latest block (current head of the blockchain)"pending"
- String: The currently mined block (including pending transactions)"finalized"
- String: (For POS networks) The finalized block is one which has been accepted as canonical by greater than 2/3 of validators"safe"
- String: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work network's latest blocks.
Parameters
val: BlockNumberOrTag
Returns void
defaultChain
Returns string
Parameters
val: string
Returns void
defaultCommon
Will get the default common property The default common property does contain the following Common object:
customChain
-Object
: The custom chain propertiesname
-string
: (optional) The name of the chainnetworkId
-number
: Network ID of the custom chainchainId
-number
: Chain ID of the custom chain
baseChain
-string
: (optional) mainnet, goerli, kovan, rinkeby, or ropstenhardfork
-string
: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london Default isundefined
.
Returns undefined | Common
Will set the default common property
Parameters
val: undefined | Common
Returns void
defaultHardfork
Will return the default hardfork. Default is
london
The default hardfork property can be one of the following:chainstart
homestead
dao
tangerineWhistle
spuriousDragon
byzantium
constantinople
petersburg
istanbul
berlin
london
- 'arrowGlacier',
- 'tangerineWhistle',
- 'muirGlacier'
Returns string
Will set the default hardfork.
Parameters
val: string
Returns void
defaultMaxPriorityFeePerGas
defaultNetworkId
defaultReturnFormat
Returns DataFormat
Parameters
val: DataFormat
Returns void
defaultTransactionType
enableExperimentalFeatures
The enableExperimentalFeatures is used to enable trying new experimental features that are still not fully implemented or not fully tested or still have some related issues. Default is
false
for every feature.Returns { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }
useRpcCallSpecification: boolean
useSubscriptionWhenCheckingBlockTimeout: boolean
Will set the enableExperimentalFeatures
Parameters
val: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }
useRpcCallSpecification: boolean
useSubscriptionWhenCheckingBlockTimeout: boolean
Returns void
events
Returns ContractEventsInterface<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes32; name: label; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: NewOwner; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: resolver; type: address }]; name: NewResolver; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: Transfer; type: event }, { inputs: readonly [{ internalType: address; name: owner; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: owner; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: recordExists; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: resolver; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: ttl; outputs: readonly [{ internalType: uint64; name: ; type: uint64 }]; stateMutability: view; type: function }], ContractEvents<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes32; name: label; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: NewOwner; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: resolver; type: address }]; name: NewResolver; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: owner; type: address }]; name: Transfer; type: event }, { inputs: readonly [{ internalType: address; name: owner; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: owner; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: recordExists; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: resolver; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: ttl; outputs: readonly [{ internalType: uint64; name: ; type: uint64 }]; stateMutability: view; type: function }]>>
- Returns all events that can be emitted by the ENS registry.
givenProvider
Will return the givenProvider if available.
When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise
undefined
.Returns undefined | SupportedProviders<never>
handleRevert
The
handleRevert
options property returns the revert reason string if enabled for the following methods:- web3.eth.sendTransaction()
- web3.eth.call()
- myContract.methods.myMethod().call()
- myContract.methods.myMethod().send()
Default is
false
.
Note
: At the momenthandleRevert
is only supported forsendTransaction
and not forsendSignedTransaction
Returns boolean
Will set the handleRevert
Parameters
val: boolean
Returns void
ignoreGasPricing
Will get the ignoreGasPricing property. When true, the gasPrice, maxPriorityFeePerGas, and maxFeePerGas will not be autofilled in the transaction object. Useful when you want wallets to handle gas pricing.
Returns boolean
Parameters
val: boolean
Returns void
maxListenersWarningThreshold
Returns number
Parameters
val: number
Returns void
provider
Will return the current provider.
Returns undefined | Web3BaseProvider<API>
Returns the current provider
Will set the current provider.
Parameters
provider: undefined | string | SupportedProviders<API>
The provider to set
Accepted providers are of type SupportedProviders
Returns void
requestManager
Returns Web3RequestManager<API>
subscriptionManager
Will return the current subscriptionManager (Web3SubscriptionManager)
Returns Web3SubscriptionManager<API, RegisteredSubs>
transactionBlockTimeout
The
transactionBlockTimeout
is used over socket-based connections. This option defines the amount of new blocks it should wait until the first confirmation happens, otherwise the PromiEvent rejects with a timeout error. Default is50
.Returns number
Will set the transactionBlockTimeout.
Parameters
val: number
Returns void
transactionBuilder
Returns undefined | TransactionBuilder<unknown>
Parameters
val: undefined | TransactionBuilder<unknown>
Returns void
transactionConfirmationBlocks
This defines the number of blocks it requires until a transaction is considered confirmed. Default is
24
.Returns number
Will set the transactionConfirmationBlocks.
Parameters
val: number
Returns void
transactionConfirmationPollingInterval
Returns undefined | number
Parameters
val: undefined | number
Returns void
transactionPollingInterval
Used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network. Default is
1000
ms.Returns number
Will set the transactionPollingInterval.
Parameters
val: number
Returns void
transactionPollingTimeout
Used over HTTP connections. This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. Note: If this method times out, the transaction may still be pending. Default is
750
seconds (12.5 minutes).Returns number
Will set the transactionPollingTimeout.
Parameters
val: number
Returns void
transactionReceiptPollingInterval
The
transactionPollingInterval
is used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network. Default isundefined
Returns undefined | number
Will set the transactionReceiptPollingInterval
Parameters
val: undefined | number
Returns void
transactionSendTimeout
The time used to wait for Ethereum Node to return the sent transaction result. Note: If the RPC call stuck at the Node and therefor timed-out, the transaction may still be pending or even mined by the Network. We recommend checking the pending transactions in such a case. Default is
750
seconds (12.5 minutes).Returns number
Will set the transactionSendTimeout.
Parameters
val: number
Returns void
transactionTypeParser
Returns undefined | TransactionTypeParser
Parameters
val: undefined | TransactionTypeParser
Returns void
wallet
Returns undefined | Web3BaseWallet<Web3BaseWalletAccount>
checkNetwork
Checks if the current used network is synced and looks for ENS support there. Throws an error if not.
Returns Promise<string>
- The address of the ENS registry if the network has been detected successfully
emit
Type parameters
- K: CONFIG_CHANGE
Parameters
eventName: K
params: { CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[K]
Returns void
eventNames
Returns (string | symbol)[]
extend
This method allows extending the web3 modules. Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
Parameters
extendObj: ExtensionObject
Returns this
getAddress
Resolves an ENS name to an Ethereum address.
Parameters
ENSName: string
The ENS name to resolve
optionalcoinType: number
(Optional) The coin type, defaults to 60 (ETH)
Returns Promise<MatchPrimitiveType<bytes, unknown>>
- The Ethereum address of the given name
const address = await web3.eth.ens.getAddress('ethereum.eth');
console.log(address);
> '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'
getContenthash
Returns the content hash object associated with an ENS node.
Parameters
ENSName: string
The ENS name
Returns Promise<MatchPrimitiveType<bytes, unknown>>
- The content hash object associated with an ENS node
getContextObject
Returns Web3ContextObject<EthExecutionAPI & Web3NetAPI, any>
getMaxListeners
Returns number
getName
Resolves the name of an ENS node.
Parameters
ENSName: string
The node to resolve
optionalcheckInterfaceSupport: boolean
Returns Promise<string>
- The name
getOwner
Returns the owner by the given name and current configured or detected Registry
Parameters
name: string
The ENS name
Returns Promise<unknown>
- Returns the address of the owner of the name.
getPubkey
Returns the X and Y coordinates of the curve point for the public key.
Parameters
ENSName: string
The ENS name
Returns Promise<unknown[] & Record<1, MatchPrimitiveType<bytes32, unknown>> & Record<0, MatchPrimitiveType<bytes32, unknown>> & [] & Record<x, MatchPrimitiveType<bytes32, unknown>> & Record<y, MatchPrimitiveType<bytes32, unknown>>>
- The X and Y coordinates of the curve point for the public key
getResolver
Returns the Resolver by the given address
Parameters
name: string
The name of the ENS domain
Returns Promise<Contract<readonly [{ anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: address; name: a; type: address }]; name: AddrChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: uint256; name: coinType; type: uint256 }, { indexed: false; internalType: bytes; name: newAddress; type: bytes }]; name: AddressChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: address; name: owner; type: address }, { indexed: true; internalType: address; name: operator; type: address }, { indexed: false; internalType: bool; name: approved; type: bool }]; name: ApprovalForAll; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: hash; type: bytes }]; name: ContenthashChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: name; type: bytes }, { indexed: false; internalType: uint16; name: resource; type: uint16 }, { indexed: false; internalType: bytes; name: record; type: bytes }]; name: DNSRecordChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: name; type: bytes }, { indexed: false; internalType: uint16; name: resource; type: uint16 }]; name: DNSRecordDeleted; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }]; name: DNSZoneCleared; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes; name: lastzonehash; type: bytes }, { indexed: false; internalType: bytes; name: zonehash; type: bytes }]; name: DNSZonehashChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: bytes4; name: interfaceID; type: bytes4 }, { indexed: false; internalType: address; name: implementer; type: address }]; name: InterfaceChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: string; name: name; type: string }]; name: NameChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: false; internalType: bytes32; name: x; type: bytes32 }, { indexed: false; internalType: bytes32; name: y; type: bytes32 }]; name: PubkeyChanged; type: event }, { anonymous: false; inputs: readonly [{ indexed: true; internalType: bytes32; name: node; type: bytes32 }, { indexed: true; internalType: string; name: indexedKey; type: string }, { indexed: false; internalType: string; name: key; type: string }]; name: TextChanged; type: event }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: uint256; name: contentTypes; type: uint256 }]; name: ABI; outputs: readonly [{ internalType: uint256; name: ; type: uint256 }, { internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: addr; outputs: readonly [{ internalType: address payable; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: uint256; name: coinType; type: uint256 }]; name: addr; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: contenthash; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes32; name: name; type: bytes32 }, { internalType: uint16; name: resource; type: uint16 }]; name: dnsRecord; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes32; name: name; type: bytes32 }]; name: hasDNSRecords; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: bytes4; name: interfaceID; type: bytes4 }]; name: interfaceImplementer; outputs: readonly [{ internalType: address; name: ; type: address }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: address; name: account; type: address }, { internalType: address; name: operator; type: address }]; name: isApprovedForAll; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: name; outputs: readonly [{ internalType: string; name: ; type: string }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: pubkey; outputs: readonly [{ internalType: bytes32; name: x; type: bytes32 }, { internalType: bytes32; name: y; type: bytes32 }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes4; name: interfaceID; type: bytes4 }]; name: supportsInterface; outputs: readonly [{ internalType: bool; name: ; type: bool }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: string; name: key; type: string }]; name: text; outputs: readonly [{ internalType: string; name: ; type: string }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }]; name: zonehash; outputs: readonly [{ internalType: bytes; name: ; type: bytes }]; stateMutability: view; type: function }, { inputs: readonly [{ internalType: bytes32; name: node; type: bytes32 }, { internalType: address; name: a; type: address }]; name: setAddr; outputs: readonly []; stateMutability: nonpayable; type: function }]>>
- An contract instance of the resolver
getTTL
Returns the caching TTL (time-to-live) of an ENS name.
Parameters
name: string
The ENS name
Returns Promise<unknown>
- Returns the caching TTL (time-to-live) of a name.
getText
ERC-634 - Returns the text content stored in the resolver for the specified key.
Parameters
ENSNameOrAddr: string
key: string
The key to resolve https://github.com/ethereum/ercs/blob/master/ERCS/erc-634.md#global-keys
Returns Promise<string>
- The value content stored in the resolver for the specified key
link
Link current context to another context.
Type parameters
- T: Web3Context<unknown, any, T>
Parameters
parentContext: T
Returns void
listenerCount
Type parameters
- K: CONFIG_CHANGE
Parameters
eventName: K
Returns number
listeners
Type parameters
- K: CONFIG_CHANGE
Parameters
eventName: K
Returns (...args: any[]) => void[]
off
Type parameters
- K: CONFIG_CHANGE
Parameters
eventName: K
fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[K]>
Returns void
on
Type parameters
- K: CONFIG_CHANGE
Parameters
eventName: K
fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[K]>
Returns void
once
Type parameters
- K: CONFIG_CHANGE
Parameters
eventName: K
fn: Web3EventCallback<{ CONFIG_CHANGE: { name: handleRevert; newValue: boolean; oldValue: boolean } | { name: defaultAccount; newValue: undefined | string; oldValue: undefined | string } | { name: defaultBlock; newValue: BlockNumberOrTag; oldValue: BlockNumberOrTag } | { name: transactionSendTimeout; newValue: number; oldValue: number } | { name: transactionBlockTimeout; newValue: number; oldValue: number } | { name: transactionConfirmationBlocks; newValue: number; oldValue: number } | { name: transactionPollingInterval; newValue: number; oldValue: number } | { name: transactionPollingTimeout; newValue: number; oldValue: number } | { name: transactionReceiptPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: transactionConfirmationPollingInterval; newValue: undefined | number; oldValue: undefined | number } | { name: blockHeaderTimeout; newValue: number; oldValue: number } | { name: maxListenersWarningThreshold; newValue: number; oldValue: number } | { name: contractDataInputFill; newValue: input | data | both; oldValue: input | data | both } | { name: defaultNetworkId; newValue: undefined | Numbers; oldValue: undefined | Numbers } | { name: defaultChain; newValue: string; oldValue: string } | { name: defaultHardfork; newValue: string; oldValue: string } | { name: ignoreGasPricing; newValue: boolean; oldValue: boolean } | { name: defaultCommon; newValue: undefined | Common; oldValue: undefined | Common } | { name: defaultTransactionType; newValue: Numbers; oldValue: Numbers } | { name: defaultMaxPriorityFeePerGas; newValue: Numbers; oldValue: Numbers } | { name: enableExperimentalFeatures; newValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean }; oldValue: { useRpcCallSpecification: boolean; useSubscriptionWhenCheckingBlockTimeout: boolean } } | { name: transactionBuilder; newValue: undefined | TransactionBuilder<unknown>; oldValue: undefined | TransactionBuilder<unknown> } | { name: transactionTypeParser; newValue: undefined | TransactionTypeParser; oldValue: undefined | TransactionTypeParser } | { name: customTransactionSchema; newValue: undefined | CustomTransactionSchema; oldValue: undefined | CustomTransactionSchema } | { name: defaultReturnFormat; newValue: DataFormat; oldValue: DataFormat } }[K]>
Returns void
recordExists
Returns true if the record exists
Parameters
name: string
The ENS name
Returns Promise<unknown>
- Returns
true
if node exists in this ENS registry. This will returnfalse
for records that are in the legacy ENS registry but have not yet been migrated to the new one.
registerPlugin
Parameters
plugin: Web3PluginBase<unknown>
Returns void
removeAllListeners
Returns EventEmitter
setAddress
Sets the address of an ENS name in his resolver.
Parameters
name: string
The ENS name
address: string
The address to set
txConfig: PayableCallOptions
(Optional) The transaction config
Returns Promise<TransactionReceipt | RevertInstructionError>
- The transaction receipt
const receipt = await ens.setAddress('web3js.eth','0xe2597eb05cf9a87eb1309e86750c903ec38e527e');
setConfig
Parameters
options: Partial<Web3ConfigOptions>
Returns void
setMaxListenerWarningThreshold
Parameters
maxListenersWarningThreshold: number
Returns void
setProvider
Will set the provider.
Parameters
optionalprovider: string | SupportedProviders<EthExecutionAPI & Web3NetAPI>
SupportedProviders The provider to set
Returns boolean
Returns true if the provider was set
setRequestManagerMiddleware
Parameters
requestManagerMiddleware: RequestManagerMiddleware<EthExecutionAPI & Web3NetAPI>
Returns void
supportsInterface
Returns true if the related Resolver does support the given signature or interfaceId.
Parameters
ENSName: string
The ENS name
interfaceId: string
The signature of the function or the interfaceId as described in the ENS documentation
Returns Promise<MatchPrimitiveType<bool, unknown>>
true
if the related Resolver does support the given signature or interfaceId.
use
Use to create new object of any type extended by
Web3Context
and link it to current context. This can be used to initiate a global context object and then use it to create new objects of any type extended byWeb3Context
.Type parameters
- T: Web3Context<unknown, any, T>
- T2: unknown[]
Parameters
ContextRef: Web3ContextConstructor<T, T2>
rest...args: [...T2[]]
Returns T
staticfromContextObject
Type parameters
- T: Web3Context<unknown, any, T>
- T3: unknown[]
Parameters
this: Web3ContextConstructor<T, T3>
rest...args: [Web3ContextObject<unknown, any>, ...T3[]]
Returns T
constregistryAddresses
An object holding the addressed of the ENS registries on the different networks (mainnet, goerli).
Type declaration
[T string]: string
iban
Iban
default
IbanOptions
An object that could hold the components for an Indirect IBAN (BBAN)
Type declaration
identifier: string
institution: string
personal
Personal
default
Classes
LogsSubscription
subscribe('logs')
Subscribes to incoming logs, filtered by the given options. If a valid numerical fromBlock options property is set, web3.js will retrieve logs beginning from this point, backfilling the response as necessary.
You can subscribe to logs matching a given filter object, which can take the following parameters:
fromBlock
: (optional, default: 'latest') Integer block number, or'latest'
for the last mined block or'pending'
,'earliest'
for not yet mined transactions.address
: (optional) Contract address or a list of addresses from which logs should originate.topics
: (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA withor
options.
constructor
Parameters
args: { address?: string | string[]; fromBlock?: BlockNumberOrTag; topics?: string[] }
optionalreadonlyaddress: string | string[]
optionalreadonlyfromBlock: BlockNumberOrTag
optionalreadonlytopics: string[]
options: { returnFormat?: DataFormat; subscriptionManager: Web3SubscriptionManager<unknown, {}> }
optionalreturnFormat: DataFormat
subscriptionManager: Web3SubscriptionManager<unknown, {}>
Returns LogsSubscription
readonlyargs
Type declaration
optionalreadonlyaddress?: string | string[]
optionalreadonlyfromBlock?: BlockNumberOrTag
optionalreadonlytopics?: string[]
id
Returns undefined | string
lastBlock
Returns undefined | BlockOutput
_processSubscriptionError
Parameters
error: Error
Returns void
_processSubscriptionResult
Parameters
data: unknown
Returns void
emit
Type parameters
- K: Web3EventKey<{ data: LogsOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
params: { data: LogsOutput } & CommonSubscriptionEvents[K]
Returns void
eventNames
Returns (string | symbol)[]
getMaxListeners
Returns number
listenerCount
Type parameters
- K: Web3EventKey<{ data: LogsOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns number
listeners
Type parameters
- K: Web3EventKey<{ data: LogsOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns (...args: any[]) => void[]
off
Type parameters
- K: Web3EventKey<{ data: LogsOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: LogsOutput } & CommonSubscriptionEvents[K]>
Returns void
on
Type parameters
- K: Web3EventKey<{ data: LogsOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: LogsOutput } & CommonSubscriptionEvents[K]>
Returns void
once
Type parameters
- K: Web3EventKey<{ data: LogsOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: LogsOutput } & CommonSubscriptionEvents[K]>
Returns void
processSubscriptionData
Parameters
Returns void
removeAllListeners
Returns EventEmitter
resubscribe
Returns Promise<void>
sendSubscriptionRequest
Returns Promise<string>
sendUnsubscribeRequest
Returns Promise<void>
setMaxListenerWarningThreshold
Parameters
maxListenersWarningThreshold: number
Returns void
subscribe
Returns Promise<string>
unsubscribe
Returns Promise<void>
NewHeadsSubscription
subscribe('newHeads') ( same as subscribe('newBlockHeaders'))
Subscribes to incoming block headers. This can be used as timer to check for changes on the blockchain.
The structure of a returned block header is BlockHeaderOutput:
constructor
Parameters
args: any
options: { returnFormat?: DataFormat; subscriptionManager: Web3SubscriptionManager<unknown, {}> }
optionalreturnFormat: DataFormat
subscriptionManager: Web3SubscriptionManager<unknown, {}>
Returns NewHeadsSubscription
readonlyargs
id
Returns undefined | string
lastBlock
Returns undefined | BlockOutput
_processSubscriptionError
Parameters
error: Error
Returns void
_processSubscriptionResult
Parameters
data: unknown
Returns void
emit
Type parameters
- K: Web3EventKey<{ data: BlockHeaderOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
params: { data: BlockHeaderOutput } & CommonSubscriptionEvents[K]
Returns void
eventNames
Returns (string | symbol)[]
getMaxListeners
Returns number
listenerCount
Type parameters
- K: Web3EventKey<{ data: BlockHeaderOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns number
listeners
Type parameters
- K: Web3EventKey<{ data: BlockHeaderOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns (...args: any[]) => void[]
off
Type parameters
- K: Web3EventKey<{ data: BlockHeaderOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: BlockHeaderOutput } & CommonSubscriptionEvents[K]>
Returns void
on
Type parameters
- K: Web3EventKey<{ data: BlockHeaderOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: BlockHeaderOutput } & CommonSubscriptionEvents[K]>
Returns void
once
Type parameters
- K: Web3EventKey<{ data: BlockHeaderOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: BlockHeaderOutput } & CommonSubscriptionEvents[K]>
Returns void
processSubscriptionData
Parameters
Returns void
removeAllListeners
Returns EventEmitter
resubscribe
Returns Promise<void>
sendSubscriptionRequest
Returns Promise<string>
sendUnsubscribeRequest
Returns Promise<void>
setMaxListenerWarningThreshold
Parameters
maxListenersWarningThreshold: number
Returns void
subscribe
Returns Promise<string>
unsubscribe
Returns Promise<void>
NewPendingTransactionsSubscription
subscribe('pendingTransactions')
Subscribes to incoming pending transactions.
You can subscribe to pending transactions by calling web3.eth.subscribe('pendingTransactions').
constructor
Parameters
args: any
options: { returnFormat?: DataFormat; subscriptionManager: Web3SubscriptionManager<unknown, {}> }
optionalreturnFormat: DataFormat
subscriptionManager: Web3SubscriptionManager<unknown, {}>
Returns NewPendingTransactionsSubscription
readonlyargs
id
Returns undefined | string
lastBlock
Returns undefined | BlockOutput
_processSubscriptionError
Parameters
error: Error
Returns void
_processSubscriptionResult
Parameters
data: unknown
Returns void
emit
Type parameters
- K: Web3EventKey<{ data: string } & CommonSubscriptionEvents>
Parameters
eventName: K
params: { data: string } & CommonSubscriptionEvents[K]
Returns void
eventNames
Returns (string | symbol)[]
getMaxListeners
Returns number
listenerCount
Type parameters
- K: Web3EventKey<{ data: string } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns number
listeners
Type parameters
- K: Web3EventKey<{ data: string } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns (...args: any[]) => void[]
off
Type parameters
- K: Web3EventKey<{ data: string } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: string } & CommonSubscriptionEvents[K]>
Returns void
on
Type parameters
- K: Web3EventKey<{ data: string } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: string } & CommonSubscriptionEvents[K]>
Returns void
once
Type parameters
- K: Web3EventKey<{ data: string } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ data: string } & CommonSubscriptionEvents[K]>
Returns void
processSubscriptionData
Parameters
Returns void
removeAllListeners
Returns EventEmitter
resubscribe
Returns Promise<void>
sendSubscriptionRequest
Returns Promise<string>
sendUnsubscribeRequest
Returns Promise<void>
setMaxListenerWarningThreshold
Parameters
maxListenersWarningThreshold: number
Returns void
subscribe
Returns Promise<string>
unsubscribe
Returns Promise<void>
SendTxHelper
Type parameters
- ReturnFormat: DataFormat
- ResolveType = FormatType<TransactionReceipt, ReturnFormat>
- TxType = Transaction | TransactionWithFromLocalWalletIndex | TransactionWithToLocalWalletIndex | TransactionWithFromAndToLocalWalletIndex
constructor
Type parameters
- ReturnFormat: DataFormat
- ResolveType = { blockHash: ByteTypes[ReturnFormat[bytes]]; blockNumber: NumberTypes[ReturnFormat[number]]; contractAddress?: string; cumulativeGasUsed: NumberTypes[ReturnFormat[number]]; effectiveGasPrice?: NumberTypes[ReturnFormat[number]]; events?: {}; from: string; gasUsed: NumberTypes[ReturnFormat[number]]; logs: { address?: string; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; data?: ByteTypes[ReturnFormat[bytes]]; id?: string; logIndex?: NumberTypes[ReturnFormat[number]]; removed?: boolean; topics?: ByteTypes[ReturnFormat[bytes]][]; transactionHash?: ByteTypes[ReturnFormat[bytes]]; transactionIndex?: NumberTypes[ReturnFormat[number]] }[]; logsBloom: ByteTypes[ReturnFormat[bytes]]; root: ByteTypes[ReturnFormat[bytes]]; status: NumberTypes[ReturnFormat[number]]; to: string; transactionHash: ByteTypes[ReturnFormat[bytes]]; transactionIndex: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]] }
- TxType = Transaction | TransactionWithFromLocalWalletIndex | TransactionWithToLocalWalletIndex | TransactionWithFromAndToLocalWalletIndex
Parameters
__namedParameters: { options: SendTransactionOptions<ResolveType>; promiEvent: Web3PromiEvent<ResolveType, SendSignedTransactionEvents<ReturnFormat> | SendTransactionEvents<ReturnFormat>>; returnFormat: ReturnFormat; web3Context: Web3Context<EthExecutionAPI, any> }
options: SendTransactionOptions<ResolveType>
promiEvent: Web3PromiEvent<ResolveType, SendSignedTransactionEvents<ReturnFormat> | SendTransactionEvents<ReturnFormat>>
returnFormat: ReturnFormat
web3Context: Web3Context<EthExecutionAPI, any>
Returns SendTxHelper<ReturnFormat, ResolveType, TxType>
checkRevertBeforeSending
Parameters
tx: TransactionCall
Returns Promise<void>
emitConfirmation
emitReceipt
Parameters
receipt: ResolveType
Returns void
emitSending
Parameters
tx: string | TxType
Returns void
emitSent
Parameters
tx: string | TxType
Returns void
emitTransactionHash
Parameters
hash: string & Uint8Array
Returns void
getReceiptWithEvents
Parameters
data: TransactionReceipt
Returns ResolveType
handleError
Parameters
__namedParameters: { error: unknown; tx: TransactionCall }
error: unknown
tx: TransactionCall
Returns Promise<unknown>
handleResolve
Parameters
__namedParameters: { receipt: ResolveType; tx: TransactionCall }
receipt: ResolveType
tx: TransactionCall
Returns Promise<ResolveType>
populateGasPrice
Parameters
__namedParameters: { transaction: TxType; transactionFormatted: TxType }
transaction: TxType
transactionFormatted: TxType
Returns Promise<TxType>
signAndSend
Parameters
__namedParameters: { tx: TxType; wallet: undefined | Web3BaseWalletAccount }
tx: TxType
wallet: undefined | Web3BaseWalletAccount
Returns Promise<string>
SyncingSubscription
subscribe('syncing')
Subscribe to syncing events. This will return true
when the node is syncing and when it’s finished syncing will return false
, for the changed
event.
constructor
Parameters
args: any
options: { returnFormat?: DataFormat; subscriptionManager: Web3SubscriptionManager<unknown, {}> }
optionalreturnFormat: DataFormat
subscriptionManager: Web3SubscriptionManager<unknown, {}>
Returns SyncingSubscription
readonlyargs
id
Returns undefined | string
lastBlock
Returns undefined | BlockOutput
_processSubscriptionError
Parameters
error: Error
Returns void
_processSubscriptionResult
Parameters
data: boolean | { status: SyncOutput; syncing: boolean }
status: SyncOutput
syncing: boolean
Returns void
emit
Type parameters
- K: Web3EventKey<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
params: { changed: boolean; data: SyncOutput } & CommonSubscriptionEvents[K]
Returns void
eventNames
Returns (string | symbol)[]
getMaxListeners
Returns number
listenerCount
Type parameters
- K: Web3EventKey<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns number
listeners
Type parameters
- K: Web3EventKey<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
Returns (...args: any[]) => void[]
off
Type parameters
- K: Web3EventKey<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents[K]>
Returns void
on
Type parameters
- K: Web3EventKey<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents[K]>
Returns void
once
Type parameters
- K: Web3EventKey<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents>
Parameters
eventName: K
fn: Web3EventCallback<{ changed: boolean; data: SyncOutput } & CommonSubscriptionEvents[K]>
Returns void
processSubscriptionData
Parameters
Returns void
removeAllListeners
Returns EventEmitter
resubscribe
Returns Promise<void>
sendSubscriptionRequest
Returns Promise<string>
sendUnsubscribeRequest
Returns Promise<void>
setMaxListenerWarningThreshold
Parameters
maxListenersWarningThreshold: number
Returns void
subscribe
Returns Promise<string>
unsubscribe
Returns Promise<void>
Interfaces
RevertReason
optionaldata
reason
optionalsignature
RevertReasonWithCustomError
customErrorArguments
customErrorDecodedSignature
customErrorName
optionaldata
reason
optionalsignature
SendSignedTransactionOptions
Type parameters
- ResolveType = TransactionReceipt
optionalcheckRevertBeforeSending
optionalcontractAbi
optionaltransactionResolver
Type declaration
Parameters
receipt: TransactionReceipt
Returns ResolveType
SendTransactionOptions
Type parameters
- ResolveType = TransactionReceipt
optionalcheckRevertBeforeSending
optionalcontractAbi
optionalignoreFillingGasLimit
optionalignoreGasPricing
optionaltransactionResolver
Type declaration
Parameters
receipt: TransactionReceipt
Returns ResolveType
TransactionMiddleware
processTransaction
Parameters
transaction: TransactionMiddlewareData
optionaloptions: {}
Returns Promise<TransactionMiddlewareData>
Type Aliases
CustomTransactionSchema
Type declaration
properties: Record<string, Schema>
type: string
InternalTransaction
RegisteredSubscription
Type declaration
logs: typeof LogsSubscription
newBlockHeaders: typeof NewHeadsSubscription
newHeads: typeof NewHeadsSubscription
newPendingTransactions: typeof NewPendingTransactionsSubscription
pendingTransactions: typeof NewPendingTransactionsSubscription
syncing: typeof SyncingSubscription
SendSignedTransactionEvents
Type parameters
- ReturnFormat: DataFormat
SendTransactionEvents
Type parameters
- ReturnFormat: DataFormat
SendTransactionEventsBase
Type parameters
- ReturnFormat: DataFormat
- TxType
Type declaration
confirmation: { confirmations: FormatType<Numbers, ReturnFormat>; latestBlockHash: FormatType<Bytes, ReturnFormat>; receipt: FormatType<TransactionReceipt, ReturnFormat> }
confirmations: FormatType<Numbers, ReturnFormat>
latestBlockHash: FormatType<Bytes, ReturnFormat>
receipt: FormatType<TransactionReceipt, ReturnFormat>
error: TransactionRevertedWithoutReasonError<FormatType<TransactionReceipt, ReturnFormat>> | TransactionRevertInstructionError<FormatType<TransactionReceipt, ReturnFormat>> | TransactionRevertWithCustomError<FormatType<TransactionReceipt, ReturnFormat>> | TransactionPollingTimeoutError | InvalidResponseError | ContractExecutionError
receipt: FormatType<TransactionReceipt, ReturnFormat>
sending: FormatType<TxType, typeof ETH_DATA_FORMAT>
sent: FormatType<TxType, typeof ETH_DATA_FORMAT>
transactionHash: FormatType<Bytes, ReturnFormat>
TransactionMiddlewareData
Variables
constALL_EVENTS
constALL_EVENTS_ABI
constNUMBER_DATA_FORMAT
Type declaration
readonlybytes: FMT_BYTES.HEX
readonlynumber: FMT_NUMBER.NUMBER
constSignatureObjectSchema
Type declaration
properties: { message: { format: string }; messageHash: { format: string }; r: { format: string }; s: { format: string }; signature: { format: string }; v: { format: string } }
message: { format: string }
format: string
messageHash: { format: string }
format: string
r: { format: string }
format: string
s: { format: string }
format: string
signature: { format: string }
format: string
v: { format: string }
format: string
type: string
constaccessListItemSchema
Type declaration
properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }
address: { format: string }
format: string
storageKeys: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
type: string
constaccessListResultSchema
Type declaration
properties: { accessList: { items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }; type: string }; gasUsed: { type: string } }
accessList: { items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }; type: string }
items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }
properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }
address: { format: string }
format: string
storageKeys: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
type: string
type: string
gasUsed: { type: string }
type: string
type: string
constaccessListSchema
Type declaration
items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }
properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }
address: { format: string }
format: string
storageKeys: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
type: string
type: string
constaccountSchema
Type declaration
properties: { accountProof: { items: { format: string }; type: string }; balance: { format: string }; codeHash: { format: string }; nonce: { format: string }; storageHash: { format: string }; storageProof: { items: { properties: { key: { format: string }; proof: { items: { format: string }; type: string }; value: { format: string } }; type: string }; type: string } }
accountProof: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
balance: { format: string }
format: string
codeHash: { format: string }
format: string
nonce: { format: string }
format: string
storageHash: { format: string }
format: string
storageProof: { items: { properties: { key: { format: string }; proof: { items: { format: string }; type: string }; value: { format: string } }; type: string }; type: string }
items: { properties: { key: { format: string }; proof: { items: { format: string }; type: string }; value: { format: string } }; type: string }
properties: { key: { format: string }; proof: { items: { format: string }; type: string }; value: { format: string } }
key: { format: string }
format: string
proof: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
value: { format: string }
format: string
type: string
type: string
type: string
constblockHeaderSchema
Type declaration
properties: { author: { format: string }; baseFeePerGas: { format: string }; blobGasUsed: { format: string }; difficulty: { format: string }; excessBlobGas: { format: string }; excessDataGas: { format: string }; extraData: { format: string }; gasLimit: { format: string }; gasUsed: { format: string }; hash: { format: string }; logsBloom: { format: string }; miner: { format: string }; mixHash: { format: string }; nonce: { format: string }; number: { format: string }; parentBeaconBlockRoot: { format: string }; parentHash: { format: string }; receiptsRoot: { format: string }; sha3Uncles: { format: string }; size: { format: string }; stateRoot: { format: string }; timestamp: { format: string }; totalDifficulty: { format: string }; transactions: { items: { format: string }; type: string }; transactionsRoot: { format: string }; uncles: { items: { format: string }; type: string }; withdrawals: { items: { properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }; type: string }; type: string }; withdrawalsRoot: { format: string } }
author: { format: string }
format: string
baseFeePerGas: { format: string }
format: string
blobGasUsed: { format: string }
format: string
difficulty: { format: string }
format: string
excessBlobGas: { format: string }
format: string
excessDataGas: { format: string }
format: string
extraData: { format: string }
format: string
gasLimit: { format: string }
format: string
gasUsed: { format: string }
format: string
hash: { format: string }
format: string
logsBloom: { format: string }
format: string
miner: { format: string }
format: string
mixHash: { format: string }
format: string
nonce: { format: string }
format: string
number: { format: string }
format: string
parentBeaconBlockRoot: { format: string }
format: string
parentHash: { format: string }
format: string
receiptsRoot: { format: string }
format: string
sha3Uncles: { format: string }
format: string
size: { format: string }
format: string
stateRoot: { format: string }
format: string
timestamp: { format: string }
format: string
totalDifficulty: { format: string }
format: string
transactions: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
transactionsRoot: { format: string }
format: string
uncles: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
withdrawals: { items: { properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }; type: string }; type: string }
items: { properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }; type: string }
properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }
address: { format: string }
format: string
amount: { format: string }
format: string
index: { format: string }
format: string
validatorIndex: { format: string }
format: string
type: string
type: string
withdrawalsRoot: { format: string }
format: string
type: string
constblockSchema
Type declaration
properties: { baseFeePerGas: { format: string }; blobGasUsed: { format: string }; difficulty: { format: string }; excessBlobGas: { format: string }; extraData: { format: string }; gasLimit: { format: string }; gasUsed: { format: string }; hash: { format: string }; logsBloom: { format: string }; miner: { format: string }; mixHash: { format: string }; nonce: { format: string }; number: { format: string }; parentBeaconBlockRoot: { format: string }; parentHash: { format: string }; receiptsRoot: { format: string }; sha3Uncles: { format: string }; size: { format: string }; stateRoot: { format: string }; timestamp: { format: string }; totalDifficulty: { format: string }; transactions: { oneOf: ({ items: { format?: undefined; properties: { accessList: { items: { properties: ...; type: ... }; type: string }; blockHash: { format: string }; blockNumber: { format: string }; chain: { enum: ...[]; type: string }; chainId: { format: string }; common: { properties: { baseChain: ...; customChain: ...; hardfork: ... }; type: string }; data: { format: string }; effectiveGasPrice: { format: string }; from: { format: string }; gas: { format: string }; gasLimit: { format: string }; gasPrice: { format: string }; hardfork: { enum: ...[]; type: string }; hash: { format: string }; input: { format: string }; maxFeePerGas: { format: string }; maxPriorityFeePerGas: { format: string }; networkId: { format: string }; nonce: { format: string }; r: { format: string }; s: { format: string }; to: { oneOf: ...[] }; transactionIndex: { format: string }; type: { format: string }; v: { format: string }; value: { format: string } }; type: string }; type: string } | { items: { format: string }; type: string })[] }; transactionsRoot: { format: string }; uncles: { items: { format: string }; type: string }; withdrawals: { items: { properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }; type: string }; type: string }; withdrawalsRoot: { format: string } }
baseFeePerGas: { format: string }
format: string
blobGasUsed: { format: string }
format: string
difficulty: { format: string }
format: string
excessBlobGas: { format: string }
format: string
extraData: { format: string }
format: string
gasLimit: { format: string }
format: string
gasUsed: { format: string }
format: string
hash: { format: string }
format: string
logsBloom: { format: string }
format: string
miner: { format: string }
format: string
mixHash: { format: string }
format: string
nonce: { format: string }
format: string
number: { format: string }
format: string
parentBeaconBlockRoot: { format: string }
format: string
parentHash: { format: string }
format: string
receiptsRoot: { format: string }
format: string
sha3Uncles: { format: string }
format: string
size: { format: string }
format: string
stateRoot: { format: string }
format: string
timestamp: { format: string }
format: string
totalDifficulty: { format: string }
format: string
transactions: { oneOf: ({ items: { format?: undefined; properties: { accessList: { items: { properties: ...; type: ... }; type: string }; blockHash: { format: string }; blockNumber: { format: string }; chain: { enum: ...[]; type: string }; chainId: { format: string }; common: { properties: { baseChain: ...; customChain: ...; hardfork: ... }; type: string }; data: { format: string }; effectiveGasPrice: { format: string }; from: { format: string }; gas: { format: string }; gasLimit: { format: string }; gasPrice: { format: string }; hardfork: { enum: ...[]; type: string }; hash: { format: string }; input: { format: string }; maxFeePerGas: { format: string }; maxPriorityFeePerGas: { format: string }; networkId: { format: string }; nonce: { format: string }; r: { format: string }; s: { format: string }; to: { oneOf: ...[] }; transactionIndex: { format: string }; type: { format: string }; v: { format: string }; value: { format: string } }; type: string }; type: string } | { items: { format: string }; type: string })[] }
oneOf: ({ items: { format?: undefined; properties: { accessList: { items: { properties: ...; type: ... }; type: string }; blockHash: { format: string }; blockNumber: { format: string }; chain: { enum: ...[]; type: string }; chainId: { format: string }; common: { properties: { baseChain: ...; customChain: ...; hardfork: ... }; type: string }; data: { format: string }; effectiveGasPrice: { format: string }; from: { format: string }; gas: { format: string }; gasLimit: { format: string }; gasPrice: { format: string }; hardfork: { enum: ...[]; type: string }; hash: { format: string }; input: { format: string }; maxFeePerGas: { format: string }; maxPriorityFeePerGas: { format: string }; networkId: { format: string }; nonce: { format: string }; r: { format: string }; s: { format: string }; to: { oneOf: ...[] }; transactionIndex: { format: string }; type: { format: string }; v: { format: string }; value: { format: string } }; type: string }; type: string } | { items: { format: string }; type: string })[]
transactionsRoot: { format: string }
format: string
uncles: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
withdrawals: { items: { properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }; type: string }; type: string }
items: { properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }; type: string }
properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }
address: { format: string }
format: string
amount: { format: string }
format: string
index: { format: string }
format: string
validatorIndex: { format: string }
format: string
type: string
type: string
withdrawalsRoot: { format: string }
format: string
type: string
constchainSchema
Type declaration
enum: string[]
type: string
constcustomChainSchema
Type declaration
properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }
chainId: { format: string }
format: string
name: { format: string }
format: string
networkId: { format: string }
format: string
type: string
constfeeHistorySchema
Type declaration
properties: { baseFeePerGas: { items: { format: string }; type: string }; gasUsedRatio: { items: { type: string }; type: string }; oldestBlock: { format: string }; reward: { items: { items: { format: string }; type: string }; type: string } }
baseFeePerGas: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
gasUsedRatio: { items: { type: string }; type: string }
items: { type: string }
type: string
type: string
oldestBlock: { format: string }
format: string
reward: { items: { items: { format: string }; type: string }; type: string }
items: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
type: string
type: string
consthardforkSchema
Type declaration
enum: string[]
type: string
constlogSchema
Type declaration
properties: { address: { format: string }; blockHash: { format: string }; blockNumber: { format: string }; data: { format: string }; logIndex: { format: string }; removed: { format: string }; topics: { items: { format: string }; type: string }; transactionHash: { format: string }; transactionIndex: { format: string } }
address: { format: string }
format: string
blockHash: { format: string }
format: string
blockNumber: { format: string }
format: string
data: { format: string }
format: string
logIndex: { format: string }
format: string
removed: { format: string }
format: string
topics: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
transactionHash: { format: string }
format: string
transactionIndex: { format: string }
format: string
type: string
constregisteredSubscriptions
Type declaration
logs: typeof LogsSubscription
newBlockHeaders: typeof NewHeadsSubscription
newHeads: typeof NewHeadsSubscription
newPendingTransactions: typeof NewPendingTransactionsSubscription
pendingTransactions: typeof NewPendingTransactionsSubscription
syncing: typeof SyncingSubscription
conststorageProofSchema
Type declaration
properties: { key: { format: string }; proof: { items: { format: string }; type: string }; value: { format: string } }
key: { format: string }
format: string
proof: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
value: { format: string }
format: string
type: string
constsyncSchema
Type declaration
properties: { currentBlock: { format: string }; highestBlock: { format: string }; knownStates: { format: string }; pulledStates: { format: string }; startingBlock: { format: string } }
currentBlock: { format: string }
format: string
highestBlock: { format: string }
format: string
knownStates: { format: string }
format: string
pulledStates: { format: string }
format: string
startingBlock: { format: string }
format: string
type: string
consttransactionInfoSchema
Type declaration
properties: { accessList: { items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }; type: string }; blockHash: { format: string }; blockNumber: { format: string }; chain: { enum: string[]; type: string }; chainId: { format: string }; common: { properties: { baseChain: { enum: string[]; type: string }; customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }; hardfork: { enum: string[]; type: string } }; type: string }; data: { format: string }; effectiveGasPrice: { format: string }; from: { format: string }; gas: { format: string }; gasLimit: { format: string }; gasPrice: { format: string }; hardfork: { enum: string[]; type: string }; hash: { format: string }; input: { format: string }; maxFeePerGas: { format: string }; maxPriorityFeePerGas: { format: string }; networkId: { format: string }; nonce: { format: string }; r: { format: string }; s: { format: string }; to: { oneOf: ({ format: string; type?: undefined } | { format?: undefined; type: string })[] }; transactionIndex: { format: string }; type: { format: string }; v: { format: string }; value: { format: string } }
accessList: { items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }; type: string }
items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }
properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }
address: { format: string }
format: string
storageKeys: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
type: string
type: string
blockHash: { format: string }
format: string
blockNumber: { format: string }
format: string
chain: { enum: string[]; type: string }
enum: string[]
type: string
chainId: { format: string }
format: string
common: { properties: { baseChain: { enum: string[]; type: string }; customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }; hardfork: { enum: string[]; type: string } }; type: string }
properties: { baseChain: { enum: string[]; type: string }; customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }; hardfork: { enum: string[]; type: string } }
baseChain: { enum: string[]; type: string }
enum: string[]
type: string
customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }
properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }
chainId: { format: string }
format: string
name: { format: string }
format: string
networkId: { format: string }
format: string
type: string
hardfork: { enum: string[]; type: string }
enum: string[]
type: string
type: string
data: { format: string }
format: string
effectiveGasPrice: { format: string }
format: string
from: { format: string }
format: string
gas: { format: string }
format: string
gasLimit: { format: string }
format: string
gasPrice: { format: string }
format: string
hardfork: { enum: string[]; type: string }
enum: string[]
type: string
hash: { format: string }
format: string
input: { format: string }
format: string
maxFeePerGas: { format: string }
format: string
maxPriorityFeePerGas: { format: string }
format: string
networkId: { format: string }
format: string
nonce: { format: string }
format: string
r: { format: string }
format: string
s: { format: string }
format: string
to: { oneOf: ({ format: string; type?: undefined } | { format?: undefined; type: string })[] }
oneOf: ({ format: string; type?: undefined } | { format?: undefined; type: string })[]
transactionIndex: { format: string }
format: string
type: { format: string }
format: string
v: { format: string }
format: string
value: { format: string }
format: string
type: string
consttransactionReceiptSchema
Type declaration
properties: { blockHash: { format: string }; blockNumber: { format: string }; contractAddress: { format: string }; cumulativeGasUsed: { format: string }; effectiveGasPrice: { format: string }; from: { format: string }; gasUsed: { format: string }; logs: { items: { properties: { address: { format: string }; blockHash: { format: string }; blockNumber: { format: string }; data: { format: string }; logIndex: { format: string }; removed: { format: string }; topics: { items: { format: string }; type: string }; transactionHash: { format: string }; transactionIndex: { format: string } }; type: string }; type: string }; logsBloom: { format: string }; root: { format: string }; status: { format: string }; to: { format: string }; transactionHash: { format: string }; transactionIndex: { format: string }; type: { format: string } }
blockHash: { format: string }
format: string
blockNumber: { format: string }
format: string
contractAddress: { format: string }
format: string
cumulativeGasUsed: { format: string }
format: string
effectiveGasPrice: { format: string }
format: string
from: { format: string }
format: string
gasUsed: { format: string }
format: string
logs: { items: { properties: { address: { format: string }; blockHash: { format: string }; blockNumber: { format: string }; data: { format: string }; logIndex: { format: string }; removed: { format: string }; topics: { items: { format: string }; type: string }; transactionHash: { format: string }; transactionIndex: { format: string } }; type: string }; type: string }
items: { properties: { address: { format: string }; blockHash: { format: string }; blockNumber: { format: string }; data: { format: string }; logIndex: { format: string }; removed: { format: string }; topics: { items: { format: string }; type: string }; transactionHash: { format: string }; transactionIndex: { format: string } }; type: string }
properties: { address: { format: string }; blockHash: { format: string }; blockNumber: { format: string }; data: { format: string }; logIndex: { format: string }; removed: { format: string }; topics: { items: { format: string }; type: string }; transactionHash: { format: string }; transactionIndex: { format: string } }
address: { format: string }
format: string
blockHash: { format: string }
format: string
blockNumber: { format: string }
format: string
data: { format: string }
format: string
logIndex: { format: string }
format: string
removed: { format: string }
format: string
topics: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
transactionHash: { format: string }
format: string
transactionIndex: { format: string }
format: string
type: string
type: string
logsBloom: { format: string }
format: string
root: { format: string }
format: string
status: { format: string }
format: string
to: { format: string }
format: string
transactionHash: { format: string }
format: string
transactionIndex: { format: string }
format: string
type: { format: string }
format: string
type: string
consttransactionSchema
Type declaration
properties: { accessList: { items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }; type: string }; chain: { enum: string[]; type: string }; chainId: { format: string }; common: { properties: { baseChain: { enum: string[]; type: string }; customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }; hardfork: { enum: string[]; type: string } }; type: string }; data: { format: string }; effectiveGasPrice: { format: string }; from: { format: string }; gas: { format: string }; gasLimit: { format: string }; gasPrice: { format: string }; hardfork: { enum: string[]; type: string }; input: { format: string }; maxFeePerGas: { format: string }; maxPriorityFeePerGas: { format: string }; networkId: { format: string }; nonce: { format: string }; r: { format: string }; s: { format: string }; to: { oneOf: ({ format: string; type?: undefined } | { format?: undefined; type: string })[] }; type: { format: string }; v: { format: string }; value: { format: string } }
accessList: { items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }; type: string }
items: { properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }; type: string }
properties: { address: { format: string }; storageKeys: { items: { format: string }; type: string } }
address: { format: string }
format: string
storageKeys: { items: { format: string }; type: string }
items: { format: string }
format: string
type: string
type: string
type: string
chain: { enum: string[]; type: string }
enum: string[]
type: string
chainId: { format: string }
format: string
common: { properties: { baseChain: { enum: string[]; type: string }; customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }; hardfork: { enum: string[]; type: string } }; type: string }
properties: { baseChain: { enum: string[]; type: string }; customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }; hardfork: { enum: string[]; type: string } }
baseChain: { enum: string[]; type: string }
enum: string[]
type: string
customChain: { properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }; type: string }
properties: { chainId: { format: string }; name: { format: string }; networkId: { format: string } }
chainId: { format: string }
format: string
name: { format: string }
format: string
networkId: { format: string }
format: string
type: string
hardfork: { enum: string[]; type: string }
enum: string[]
type: string
type: string
data: { format: string }
format: string
effectiveGasPrice: { format: string }
format: string
from: { format: string }
format: string
gas: { format: string }
format: string
gasLimit: { format: string }
format: string
gasPrice: { format: string }
format: string
hardfork: { enum: string[]; type: string }
enum: string[]
type: string
input: { format: string }
format: string
maxFeePerGas: { format: string }
format: string
maxPriorityFeePerGas: { format: string }
format: string
networkId: { format: string }
format: string
nonce: { format: string }
format: string
r: { format: string }
format: string
s: { format: string }
format: string
to: { oneOf: ({ format: string; type?: undefined } | { format?: undefined; type: string })[] }
oneOf: ({ format: string; type?: undefined } | { format?: undefined; type: string })[]
type: { format: string }
format: string
v: { format: string }
format: string
value: { format: string }
format: string
type: string
constwithdrawalsSchema
Type declaration
properties: { address: { format: string }; amount: { format: string }; index: { format: string }; validatorIndex: { format: string } }
address: { format: string }
format: string
amount: { format: string }
format: string
index: { format: string }
format: string
validatorIndex: { format: string }
format: string
type: string
Functions
call
View additional documentations here: Web3Eth.call
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transaction: TransactionCall
optionalblockNumber: BlockNumberOrTag
optionalreturnFormat: ReturnFormat
Returns Promise<ByteTypes[ReturnFormat[bytes]]>
createAccessList
View additional documentations here: Web3Eth.createAccessList
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transaction: TransactionForAccessList
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<{ accessList?: { address?: string; storageKeys?: string[] }[]; gasUsed?: NumberTypes[ReturnFormat[number]] }>
detectTransactionType
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
optionalweb3Context: Web3Context<EthExecutionAPI, any>
Returns undefined | string
estimateGas
View additional documentations here: Web3Eth.estimateGas
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transaction: Transaction
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
formatTransaction
Type parameters
- ReturnFormat: DataFormat = { bytes: HEX; number: BIGINT }
- TransactionType: Transaction = Transaction
Parameters
transaction: TransactionType
optionalreturnFormat: ReturnFormat
optionaloptions: { fillInputAndData?: boolean; transactionSchema?: ValidationSchemaInput | CustomTransactionSchema }
optionalfillInputAndData: boolean
optionaltransactionSchema: ValidationSchemaInput | CustomTransactionSchema
Returns FormatType<TransactionType, ReturnFormat>
getBalance
View additional documentations here: Web3Eth.getBalance
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getBlock
View additional documentations here: Web3Eth.getBlock
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
block: undefined | string | number | bigint | Uint8Array
hydrated: undefined | boolean
returnFormat: ReturnFormat
Returns Promise<{ baseFeePerGas?: NumberTypes[ReturnFormat[number]]; difficulty?: NumberTypes[ReturnFormat[number]]; extraData: ByteTypes[ReturnFormat[bytes]]; gasLimit: NumberTypes[ReturnFormat[number]]; gasUsed: NumberTypes[ReturnFormat[number]]; hash?: ByteTypes[ReturnFormat[bytes]]; logsBloom?: ByteTypes[ReturnFormat[bytes]]; miner: ByteTypes[ReturnFormat[bytes]]; mixHash: ByteTypes[ReturnFormat[bytes]]; nonce: NumberTypes[ReturnFormat[number]]; number: NumberTypes[ReturnFormat[number]]; parentHash: ByteTypes[ReturnFormat[bytes]]; receiptsRoot: ByteTypes[ReturnFormat[bytes]]; sha3Uncles: ByteTypes[ReturnFormat[bytes]]; size: NumberTypes[ReturnFormat[number]]; stateRoot: ByteTypes[ReturnFormat[bytes]]; timestamp: NumberTypes[ReturnFormat[number]]; totalDifficulty: NumberTypes[ReturnFormat[number]]; transactions: string[] | { accessList?: { address?: string; storageKeys?: string[] }[]; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; chain?: ValidChains; chainId?: NumberTypes[ReturnFormat[number]]; common?: { baseChain?: ValidChains; customChain: { chainId: NumberTypes[ReturnFormat[number]]; name?: string; networkId: NumberTypes[ReturnFormat[number]] }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: ByteTypes[ReturnFormat[bytes]]; from: string; gas?: NumberTypes[ReturnFormat[number]]; gasLimit?: NumberTypes[ReturnFormat[number]]; gasPrice?: NumberTypes[ReturnFormat[number]]; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; hash: ByteTypes[ReturnFormat[bytes]]; input?: ByteTypes[ReturnFormat[bytes]]; maxFeePerGas?: NumberTypes[ReturnFormat[number]]; maxPriorityFeePerGas?: NumberTypes[ReturnFormat[number]]; networkId?: NumberTypes[ReturnFormat[number]]; nonce?: NumberTypes[ReturnFormat[number]]; r?: ByteTypes[ReturnFormat[bytes]]; s?: ByteTypes[ReturnFormat[bytes]]; to?: string | null; transactionIndex?: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]]; v?: NumberTypes[ReturnFormat[number]]; value?: NumberTypes[ReturnFormat[number]]; yParity?: string }[]; transactionsRoot: ByteTypes[ReturnFormat[bytes]]; uncles: string[] }>
getBlockNumber
View additional documentations here: Web3Eth.getBlockNumber
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getBlockTransactionCount
View additional documentations here: Web3Eth.getBlockTransactionCount
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
block: undefined | string | number | bigint | Uint8Array
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getBlockUncleCount
View additional documentations here: Web3Eth.getBlockUncleCount
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
block: undefined | string | number | bigint | Uint8Array
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getChainId
View additional documentations here: Web3Eth.getChainId
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getCode
View additional documentations here: Web3Eth.getCode
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<ByteTypes[ReturnFormat[bytes]]>
getCoinbase
View additional documentations here: Web3Eth.getCoinbase
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
Returns Promise<string>
getFeeHistory
View additional documentations here: Web3Eth.getFeeHistory
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
blockCount: Numbers
newestBlock: undefined | BlockNumberOrTag
rewardPercentiles: Numbers[]
returnFormat: ReturnFormat
Returns Promise<{ baseFeePerGas: NumberTypes[ReturnFormat[number]][]; gasUsedRatio: NumberTypes[ReturnFormat[number]][]; oldestBlock: NumberTypes[ReturnFormat[number]]; reward: NumberTypes[ReturnFormat[number]][][] }>
getGasPrice
View additional documentations here: Web3Eth.getGasPrice
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getHashRate
View additional documentations here: Web3Eth.getHashRate
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getLogs
View additional documentations here: Web3Eth.getPastLogs
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<Web3EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
filter: Filter
returnFormat: ReturnFormat
Returns Promise<(string | { address?: string; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; data?: ByteTypes[ReturnFormat[bytes]]; id?: string; logIndex?: NumberTypes[ReturnFormat[number]]; removed?: boolean; topics?: ByteTypes[ReturnFormat[bytes]][]; transactionHash?: ByteTypes[ReturnFormat[bytes]]; transactionIndex?: NumberTypes[ReturnFormat[number]] })[]>
getMaxPriorityFeePerGas
View additional documentations here: Web3Eth.getMaxPriorityFeePerGas
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getPendingTransactions
View additional documentations here: Web3Eth.getPendingTransactions
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
returnFormat: ReturnFormat
Returns Promise<{ accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: NumberTypes[ReturnFormat[number]]; common?: { baseChain?: ValidChains; customChain: { chainId: NumberTypes[ReturnFormat[number]]; name?: string; networkId: NumberTypes[ReturnFormat[number]] }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: ByteTypes[ReturnFormat[bytes]]; from?: string; gas?: NumberTypes[ReturnFormat[number]]; gasLimit?: NumberTypes[ReturnFormat[number]]; gasPrice?: NumberTypes[ReturnFormat[number]]; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: ByteTypes[ReturnFormat[bytes]]; maxFeePerGas?: NumberTypes[ReturnFormat[number]]; maxPriorityFeePerGas?: NumberTypes[ReturnFormat[number]]; networkId?: NumberTypes[ReturnFormat[number]]; nonce?: NumberTypes[ReturnFormat[number]]; r?: ByteTypes[ReturnFormat[bytes]]; s?: ByteTypes[ReturnFormat[bytes]]; to?: string | null; type?: NumberTypes[ReturnFormat[number]]; v?: NumberTypes[ReturnFormat[number]]; value?: NumberTypes[ReturnFormat[number]]; yParity?: string }[]>
getProof
View additional documentations here: Web3Eth.getProof
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<Web3EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
storageKeys: Bytes[]
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<{ accountProof: ByteTypes[ReturnFormat[bytes]][]; balance: NumberTypes[ReturnFormat[number]]; codeHash: ByteTypes[ReturnFormat[bytes]]; nonce: NumberTypes[ReturnFormat[number]]; storageHash: ByteTypes[ReturnFormat[bytes]]; storageProof: { key: ByteTypes[ReturnFormat[bytes]]; proof: ByteTypes[ReturnFormat[bytes]][]; value: NumberTypes[ReturnFormat[number]] }[] }>
getProtocolVersion
View additional documentations here: Web3Eth.getProtocolVersion
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
Returns Promise<string>
getStorageAt
View additional documentations here: Web3Eth.getStorageAt
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
storageSlot: Numbers
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<ByteTypes[ReturnFormat[bytes]]>
getTransaction
View additional documentations here: Web3Eth.getTransaction
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transactionHash: Bytes
optionalreturnFormat: ReturnFormat
Returns Promise<{ accessList: { address?: string; storageKeys?: string[] }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; maxFeePerGas: string; maxPriorityFeePerGas: string; nonce: string; r: string; s: string; to?: string | null; transactionIndex?: string; type: string; v?: undefined; value: string; yParity: string } | { accessList: { address?: string; storageKeys?: string[] }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: string; r: string; s: string; to?: string | null; transactionIndex?: string; type: string; v?: undefined; value: string; yParity: string } | { accessList?: undefined; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: string; r: string; s: string; to?: string | null; transactionIndex?: string; type: string; v: string; value: string } | undefined>
getTransactionCount
View additional documentations here: Web3Eth.getTransactionCount
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
blockNumber: undefined | BlockNumberOrTag
returnFormat: ReturnFormat
Returns Promise<NumberTypes[ReturnFormat[number]]>
getTransactionFromBlock
View additional documentations here: Web3Eth.getTransactionFromBlock
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
block: undefined | string | number | bigint | Uint8Array
transactionIndex: Numbers
returnFormat: ReturnFormat
Returns Promise<{ accessList: { address?: string; storageKeys?: string[] }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; maxFeePerGas: string; maxPriorityFeePerGas: string; nonce: string; r: string; s: string; to?: string | null; transactionIndex?: string; type: string; v?: undefined; value: string; yParity: string } | { accessList: { address?: string; storageKeys?: string[] }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: string; r: string; s: string; to?: string | null; transactionIndex?: string; type: string; v?: undefined; value: string; yParity: string } | { accessList?: undefined; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: string; r: string; s: string; to?: string | null; transactionIndex?: string; type: string; v: string; value: string } | undefined>
getTransactionFromOrToAttr
Parameters
attr: from | to
web3Context: Web3Context<EthExecutionAPI, any>
optionaltransaction: Transaction | TransactionWithFromLocalWalletIndex | TransactionWithToLocalWalletIndex | TransactionWithFromAndToLocalWalletIndex
optionalprivateKey: string | Uint8Array
Returns undefined | string
getTransactionReceipt
View additional documentations here: Web3Eth.getTransactionReceipt
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transactionHash: Bytes
returnFormat: ReturnFormat
Returns Promise<{ blockHash: ByteTypes[ReturnFormat[bytes]]; blockNumber: NumberTypes[ReturnFormat[number]]; contractAddress?: string; cumulativeGasUsed: NumberTypes[ReturnFormat[number]]; effectiveGasPrice?: NumberTypes[ReturnFormat[number]]; events?: {}; from: string; gasUsed: NumberTypes[ReturnFormat[number]]; logs: { address?: string; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; data?: ByteTypes[ReturnFormat[bytes]]; id?: string; logIndex?: NumberTypes[ReturnFormat[number]]; removed?: boolean; topics?: ByteTypes[ReturnFormat[bytes]][]; transactionHash?: ByteTypes[ReturnFormat[bytes]]; transactionIndex?: NumberTypes[ReturnFormat[number]] }[]; logsBloom: ByteTypes[ReturnFormat[bytes]]; root: ByteTypes[ReturnFormat[bytes]]; status: NumberTypes[ReturnFormat[number]]; to: string; transactionHash: ByteTypes[ReturnFormat[bytes]]; transactionIndex: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]] } | undefined>
getUncle
View additional documentations here: Web3Eth.getUncle
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
block: undefined | string | number | bigint | Uint8Array
uncleIndex: Numbers
returnFormat: ReturnFormat
Returns Promise<{ baseFeePerGas?: NumberTypes[ReturnFormat[number]]; difficulty?: NumberTypes[ReturnFormat[number]]; extraData: ByteTypes[ReturnFormat[bytes]]; gasLimit: NumberTypes[ReturnFormat[number]]; gasUsed: NumberTypes[ReturnFormat[number]]; hash?: ByteTypes[ReturnFormat[bytes]]; logsBloom?: ByteTypes[ReturnFormat[bytes]]; miner: ByteTypes[ReturnFormat[bytes]]; mixHash: ByteTypes[ReturnFormat[bytes]]; nonce: NumberTypes[ReturnFormat[number]]; number: NumberTypes[ReturnFormat[number]]; parentHash: ByteTypes[ReturnFormat[bytes]]; receiptsRoot: ByteTypes[ReturnFormat[bytes]]; sha3Uncles: ByteTypes[ReturnFormat[bytes]]; size: NumberTypes[ReturnFormat[number]]; stateRoot: ByteTypes[ReturnFormat[bytes]]; timestamp: NumberTypes[ReturnFormat[number]]; totalDifficulty: NumberTypes[ReturnFormat[number]]; transactions: string[] | { accessList?: { address?: string; storageKeys?: string[] }[]; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; chain?: ValidChains; chainId?: NumberTypes[ReturnFormat[number]]; common?: { baseChain?: ValidChains; customChain: { chainId: NumberTypes[ReturnFormat[number]]; name?: string; networkId: NumberTypes[ReturnFormat[number]] }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: ByteTypes[ReturnFormat[bytes]]; from: string; gas?: NumberTypes[ReturnFormat[number]]; gasLimit?: NumberTypes[ReturnFormat[number]]; gasPrice?: NumberTypes[ReturnFormat[number]]; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; hash: ByteTypes[ReturnFormat[bytes]]; input?: ByteTypes[ReturnFormat[bytes]]; maxFeePerGas?: NumberTypes[ReturnFormat[number]]; maxPriorityFeePerGas?: NumberTypes[ReturnFormat[number]]; networkId?: NumberTypes[ReturnFormat[number]]; nonce?: NumberTypes[ReturnFormat[number]]; r?: ByteTypes[ReturnFormat[bytes]]; s?: ByteTypes[ReturnFormat[bytes]]; to?: string | null; transactionIndex?: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]]; v?: NumberTypes[ReturnFormat[number]]; value?: NumberTypes[ReturnFormat[number]]; yParity?: string }[]; transactionsRoot: ByteTypes[ReturnFormat[bytes]]; uncles: string[] }>
isAccessList
Parameters
value: AccessList
Returns boolean
isAccessListEntry
Parameters
value: AccessListEntry
Returns boolean
isBaseTransaction
Parameters
value: BaseTransactionAPI
Returns boolean
isMining
View additional documentations here: Web3Eth.isMining
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
Returns Promise<boolean>
isSyncing
View additional documentations here: Web3Eth.isSyncing
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
Returns Promise<SyncingStatusAPI>
isTransaction1559Unsigned
Parameters
value: Transaction1559UnsignedAPI
Returns boolean
isTransaction2930Unsigned
Parameters
value: Transaction2930UnsignedAPI
Returns boolean
isTransactionCall
Parameters
value: TransactionCall
Returns boolean
isTransactionLegacyUnsigned
Parameters
value: TransactionLegacyUnsignedAPI
Returns boolean
isTransactionWithSender
Parameters
value: TransactionWithSenderAPI
Returns boolean
prepareTransactionForSigning
Parameters
transaction: Transaction
web3Context: Web3Context<EthExecutionAPI, any>
optionalprivateKey: string | Uint8Array
optionalfillGasPrice: boolean
optionalfillGasLimit: boolean
Returns Promise<TypedTransaction>
sendSignedTransaction
View additional documentations here: Web3Eth.sendSignedTransaction
Type parameters
- ReturnFormat: DataFormat
- ResolveType = { blockHash: ByteTypes[ReturnFormat[bytes]]; blockNumber: NumberTypes[ReturnFormat[number]]; contractAddress?: string; cumulativeGasUsed: NumberTypes[ReturnFormat[number]]; effectiveGasPrice?: NumberTypes[ReturnFormat[number]]; events?: {}; from: string; gasUsed: NumberTypes[ReturnFormat[number]]; logs: { address?: string; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; data?: ByteTypes[ReturnFormat[bytes]]; id?: string; logIndex?: NumberTypes[ReturnFormat[number]]; removed?: boolean; topics?: ByteTypes[ReturnFormat[bytes]][]; transactionHash?: ByteTypes[ReturnFormat[bytes]]; transactionIndex?: NumberTypes[ReturnFormat[number]] }[]; logsBloom: ByteTypes[ReturnFormat[bytes]]; root: ByteTypes[ReturnFormat[bytes]]; status: NumberTypes[ReturnFormat[number]]; to: string; transactionHash: ByteTypes[ReturnFormat[bytes]]; transactionIndex: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]] }
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
signedTransaction: Bytes
returnFormat: ReturnFormat
optionaloptions: SendSignedTransactionOptions<ResolveType>
Returns Web3PromiEvent<ResolveType, SendSignedTransactionEvents<ReturnFormat>>
sendTransaction
View additional documentations here: Web3Eth.sendTransaction
Type parameters
- ReturnFormat: DataFormat
- ResolveType = { blockHash: ByteTypes[ReturnFormat[bytes]]; blockNumber: NumberTypes[ReturnFormat[number]]; contractAddress?: string; cumulativeGasUsed: NumberTypes[ReturnFormat[number]]; effectiveGasPrice?: NumberTypes[ReturnFormat[number]]; events?: {}; from: string; gasUsed: NumberTypes[ReturnFormat[number]]; logs: { address?: string; blockHash?: ByteTypes[ReturnFormat[bytes]]; blockNumber?: NumberTypes[ReturnFormat[number]]; data?: ByteTypes[ReturnFormat[bytes]]; id?: string; logIndex?: NumberTypes[ReturnFormat[number]]; removed?: boolean; topics?: ByteTypes[ReturnFormat[bytes]][]; transactionHash?: ByteTypes[ReturnFormat[bytes]]; transactionIndex?: NumberTypes[ReturnFormat[number]] }[]; logsBloom: ByteTypes[ReturnFormat[bytes]]; root: ByteTypes[ReturnFormat[bytes]]; status: NumberTypes[ReturnFormat[number]]; to: string; transactionHash: ByteTypes[ReturnFormat[bytes]]; transactionIndex: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]] }
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transactionObj: Transaction | TransactionWithFromLocalWalletIndex | TransactionWithToLocalWalletIndex | TransactionWithFromAndToLocalWalletIndex
returnFormat: ReturnFormat
optionaloptions: SendTransactionOptions<ResolveType>
optionaltransactionMiddleware: TransactionMiddleware
Returns Web3PromiEvent<ResolveType, SendTransactionEvents<ReturnFormat>>
sign
View additional documentations here: Web3Eth.sign
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
message: Bytes
addressOrIndex: string | number
optionalreturnFormat: ReturnFormat
Returns Promise<{ message?: string; messageHash: string; r: string; s: string; signature: string; v: string } | ByteTypes[ReturnFormat[bytes]]>
signTransaction
View additional documentations here: Web3Eth.signTransaction
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
transaction: Transaction
optionalreturnFormat: ReturnFormat
Returns Promise<SignedTransactionInfoAPI>
signTypedData
View additional documentations here: Web3Eth.signTypedData
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
typedData: Eip712TypedData
useLegacy: boolean
returnFormat: ReturnFormat
Returns Promise<string>
transactionBuilder
Type parameters
- ReturnType_1 = Transaction
Parameters
options: { fillGasLimit?: boolean; fillGasPrice?: boolean; privateKey?: string | Uint8Array; transaction: Transaction; web3Context: Web3Context<EthExecutionAPI, any> }
optionalfillGasLimit: boolean
optionalfillGasPrice: boolean
optionalprivateKey: string | Uint8Array
transaction: Transaction
web3Context: Web3Context<EthExecutionAPI, any>
Returns Promise<ReturnType_1>
trySendTransaction
An internal function to send a transaction or throws if sending did not finish during the timeout during the blocks-timeout.
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
the context to read the configurations from
sendTransactionFunc: AsyncFunction<string, unknown>
the function that will send the transaction (could be sendTransaction or sendRawTransaction)
optionaltransactionHash: Bytes
to be used inside the exception message if there will be any exceptions.
Returns Promise<string>
the Promise
<string>returned by thesendTransactionFunc
.
validateBaseChain
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateChainInfo
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateCustomChainInfo
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateFeeMarketGas
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateGas
This method checks if all required gas properties are present for either legacy gas (type 0x0 and 0x1) OR fee market transactions (0x2)
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateHardfork
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateLegacyGas
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
Returns void
validateTransactionCall
Parameters
value: TransactionCall
Returns void
validateTransactionForSigning
Parameters
transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }
optionalaccessList: { address?: string; storageKeys?: string[] }[]
optionalchain: ValidChains
optionalchainId: string
optionalcommon: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }
optionaldata: string
optionalfrom: string
optionalgas: string
optionalgasLimit: string
optionalgasPrice: string
optionalhardfork: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella
optionalinput: string
optionalmaxFeePerGas: string
optionalmaxPriorityFeePerGas: string
optionalnetworkId: string
optionalnonce: string
optionalr: string
optionals: string
optionalto: null | string
optionaltype: string
optionalv: string
optionalvalue: string
optionalyParity: string
optionaloverrideMethod: (transaction: { accessList?: { address?: string; storageKeys?: string[] }[]; chain?: ValidChains; chainId?: string; common?: { baseChain?: ValidChains; customChain: { chainId: string; name?: string; networkId: string }; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella }; data?: string; from?: string; gas?: string; gasLimit?: string; gasPrice?: string; hardfork?: arrowGlacier | berlin | byzantium | chainstart | constantinople | dao | homestead | istanbul | london | merge | muirGlacier | petersburg | shanghai | spuriousDragon | tangerineWhistle | frontier | altair | grayGlacier | bellatrix | capella; input?: string; maxFeePerGas?: string; maxPriorityFeePerGas?: string; networkId?: string; nonce?: string; r?: string; s?: string; to?: null | string; type?: string; v?: string; value?: string; yParity?: string }) => void
optionaloptions: { transactionSchema?: CustomTransactionSchema }
optionaltransactionSchema: CustomTransactionSchema
Returns void
validateTransactionWithSender
Parameters
value: TransactionWithSenderAPI
Returns void
waitForTransactionReceipt
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
transactionHash: Bytes
returnFormat: ReturnFormat
optionalcustomGetTransactionReceipt: (web3Context: Web3Context<EthExecutionAPI, any>, transactionHash: Bytes, returnFormat: ReturnFormat) => Promise<TransactionReceipt>
Returns Promise<TransactionReceipt>
Decodes a function call data using its
JSON interface
object. The JSON interface spec documentation https://docs.soliditylang.org/en/latest/abi-spec.html#json