Movatterモバイル変換


[0]ホーム

URL:


ethers
v5.7
Documentation
Getting Started
Ethereum Basics
Events
Gas
Security
Best Practices
Provider API Keys
Application Programming Interface
Providers
Provider
JsonRpcProvider
API Providers
Other Providers
Types
BlockTag
Networkish
Network
FeeData
Block
Events and Logs
Transactions
Access Lists
Signers
Contract Interaction
Contract
ContractFactory
Example: ERC-20 Contract
Utilities
Application Binary Interface
AbiCoder
ABI Formats
Fragments
Interface
Addresses
BigNumber
Byte Manipulation
Constants
Display Logic and Input
Encoding Utilities
FixedNumber
Hashing Algorithms
HD Wallet
Logging
Property Utilities
Signing Key
Strings
Transactions
Web Utilities
Wordlists
Other Libraries
Assembly
Ethers ASM Dialect
Utilities
Abstract Syntax Tree
Hardware Wallets
Experimental
Command Line Interfaces
Sandbox Utility
Assembler
Ethereum Naming Service
TypeScript
Making Your Own
Cookbook
React Native (and ilk)
Transactions
Migration Guide
Migration: From Web3.js
Migration: From Ethers v4
Testing
Contributing and Hacking
Other Resources
Flatworm Docs
License and Copyright
Single Page
Documentation  »  API  »  Providers  »  Types

Types

BlockTag

ABlockTag specifies a specific block location in the Blockchain.

Networkish

ANetworkish may be any of the following:

Network

ANetwork represents an Ethereum network.

network.namestring

The human-readable name of the network, such ashomestead. If the network name is unknown, this will be"unknown".

network.chainIdnumber

The Chain ID of the network.

network.ensAddressstring<Address >

The address at which the ENS registry is deployed on this network.

FeeData

AFeeData object encapsulates the necessary fee data required to send a transaction, based on the best available recommendations.

feeData.gasPriceBigNumber

The gasPrice to use for legacy transactions or networks which do not support EIP-1559.

feeData.maxFeePerGasBigNumber

ThemaxFeePerGas to use for a transaction. This is based on the most recent block'sbaseFee.

feeData.maxPriorityFeePerGasBigNumber

ThemaxPriorityFeePerGas to use for a transaction. This accounts for the uncle risk and for the majority of current MEV risk.

Block

block.hashstring<DataHexString< 32 > >

The hash of this block.

block.parentHashstring<DataHexString< 32 > >

The hash of the previous block.

block.numbernumber

The height (number) of this block.

block.timestampnumber

The timestamp of this block.

block.noncestring<DataHexString >

The nonce used as part of the proof-of-work to mine this block.

This property is generally of little interest to developers.

block.difficultynumber

The difficulty target required to be met by the miner of the block.

Recently the difficulty frequently exceeds the size that a JavaScript number can safely store (53-bits), so in that case this property may be null. It is recommended to use the `_difficulty` property below, which will always return a value, but as aBigNumber.

This property is generally of little interest to developers.

block._difficultyBigNumber

The difficulty target required to be met by the miner of the block, as aBigNumber.

Recently the difficulty frequently exceeds the size that a JavaScript number can safely store (53-bits), so this property was added to safely encode the value for applications that require it.

This property is generally of little interest to developers.

block.gasLimitBigNumber

The maximum amount of gas that this block was permitted to use. This is a value that can be voted up or voted down by miners and is used to automatically adjust the bandwidth requirements of the network.

This property is generally of little interest to developers.

block.gasUsedBigNumber

The total amount of gas used by all transactions in this block.

block.minerstring

The coinbase address of this block, which indicates the address the miner that mined this block would like the subsidy reward to go to.

block.extraDatastring

This is extra data a miner may choose to include when mining a block.

This property is generally of little interest to developers.

Block (with transaction hashes)

Often only the hashes of the transactions included in a block are needed, so by default a block only contains this information, as it is substantially less data.

block.transactionsArray< string<DataHexString< 32 > > >

A list of the transactions hashes for each transaction this block includes.

BlockWithTransactions inheritsBlock

If all transactions for a block are needed, this object instead includes the full details on each transaction.

block.transactionsArray<TransactionResponse >

A list of the transactions this block includes.

Events and Logs

EventFilter

filter.addressstring<Address >

The address to filter by, ornull to match any address.

filter.topicsArray< string<Data< 32 > > | Array< string<Data< 32 > > > >

The topics to filter by ornull to match any topics.

Each entry represents anAND condition that must match, or may benull to match anything. If a given entry is an Array, then that entry is treated as anOR for any value in the entry.

SeeFilters for more details and examples on specifying complex filters.

Filter inheritsEventFilter

filter.fromBlockBlockTag

The starting block (inclusive) to search for logs matching the filter criteria.

filter.toBlockBlockTag

The end block (inclusive) to search for logs matching the filter criteria.

FilterByBlockHash inheritsEventFilter

filter.blockHashstring<DataHexString< 32 > >

The specific block (by its block hash) to search for logs matching the filter criteria.

Log

log.blockNumbernumber

The block height (number) of the block including the transaction of this log.

log.blockHashstring<DataHexString< 32 > >

The block hash of the block including the transaction of this log.

log.removedboolean

During a re-org, if a transaction is orphaned, this will be set to true to indicate the Log entry has been removed; it will likely be emitted again in the near future when another block is mined with the transaction that triggered this log, but keep in mind the values may change.

log.addressstring<Address >

The address of the contract that generated this log.

log.datastring<DataHexString >

The data included in this log.

log.topicsArray< string<DataHexString< 32 > > >

The list of topics (indexed properties) for this log.

log.transactionHashstring<DataHexString< 32 > >

The transaction hash of the transaction of this log.

log.transactionIndexnumber

The index of the transaction in the block of the transaction of this log.

log.logIndexnumber

The index of this log across all logs in the entireblock.

Transactions

TransactionRequest

A transaction request describes a transaction that is to be sent to the network or otherwise processed.

All fields are optional and may be a promise which resolves to the required type.

transactionRequest.tostring | Promise< string >

The address (or ENS name) this transaction it to.

transactionRequest.fromstring<Address > | Promise< string<Address > >

The address this transaction is from.

transactionRequest.noncenumber | Promise< number >

The nonce for this transaction. This should be set to the number of transactions ever sentfrom this address.

transactionRequest.dataDataHexString | Promise<DataHexString >

The transaction data.

transactionRequest.valueBigNumber | Promise<BigNumber >

The amount (in wei) this transaction is sending.

transactionRequest.gasLimitBigNumber | Promise<BigNumber >

The maximum amount of gas this transaction is permitted to use.

If left unspecified, ethers will useestimateGas to determine the value to use. For transactions with unpredicatable gas estimates, this may be required to specify explicitly.

transactionRequest.gasPriceBigNumber | Promise<BigNumber >

The price (in wei) per unit of gas this transaction will pay.

This may not be specified for transactions withtype set to1 or2, or ifmaxFeePerGas ormaxPriorityFeePerGas is given.

transactionRequest.maxFeePerGasBigNumber | Promise<BigNumber >

The maximum price (in wei) per unit of gas this transaction will pay for the combinedEIP-1559 block's base fee and this transaction's priority fee.

Most developers should leave this unspecified and use the default value that ethers determines from the network.

This may not be specified for transactions withtype set to0 or ifgasPrice is specified..

transactionRequest.maxPriorityFeePerGasBigNumber | Promise<BigNumber >

The price (in wei) per unit of gas this transaction will allow in addition to theEIP-1559 block's base fee to bribe miners into giving this transaction priority. This isincluded in themaxFeePerGas, so this willnot affect the total maximum cost set withmaxFeePerGas.

Most developers should leave this unspecified and use the default value that ethers determines from the network.

This may not be specified for transactions withtype set to0 or ifgasPrice is specified.

transactionRequest.chainIdnumber | Promise< number >

The chain ID this transaction is authorized on, as specified byEIP-155.

If the chain ID is 0 will disable EIP-155 and the transaction will be valid on any network. This can bedangerous and care should be taken, since it allows transactions to be replayed on networks that were possibly not intended. Intentionally-replayable transactions are also disabled by default on recent versions of Geth and require configuration to enable.

transactionRequest.typenull | number

TheEIP-2718 type of this transaction envelope, ornull for to use the network default. To force using a lagacy transaction without an envelope, use type0.

transactionRequest.accessListAccessListish

TheAccessList to include; only available forEIP-2930 andEIP-1559 transactions.

TransactionResponse inheritsTransaction

ATransactionResponse includes all properties of aTransaction as well as several properties that are useful once it has been mined.

transaction.blockNumbernumber

The number ("height") of the block this transaction was mined in. If the block has not been mined, this isnull.

transaction.blockHashstring<DataHexString< 32 > >

The hash of the block this transaction was mined in. If the block has not been mined, this isnull.

transaction.timestampnumber

The timestamp of the block this transaction was mined in. If the block has not been mined, this isnull.

transaction.confirmationsnumber

The number of blocks that have been mined (including the initial block) since this transaction was mined.

transaction.rawstring<DataHexString >

The serialized transaction. This may be null as some backends do not populate it. If this is required, it can be computed from aTransactionResponse object usingthis cookbook recipe.

transaction.wait([confirms =1])Promise<TransactionReceipt >

Resolves to theTransactionReceipt once the transaction has been included in the chain forconfirms blocks. Ifconfirms is 0, and the transaction has not been mined,null is returned.

If the transaction execution failed (i.e. the receipt status is0), aCALL_EXCEPTION error will be rejected with the following properties:

  • error.transaction - the original transaction
  • error.transactionHash - the hash of the transaction
  • error.receipt - the actual receipt, with the status of0

If the transaction is replaced by another transaction, aTRANSACTION_REPLACED error will be rejected with the following properties:

  • error.hash - the hash of the original transaction which was replaced
  • error.reason - a string reason; one of"repriced","cancelled" or"replaced"
  • error.cancelled - a boolean; a"repriced" transaction is not considered cancelled, but"cancelled" and"replaced" are
  • error.replacement - the replacement transaction (aTransactionResponse)
  • error.receipt - the receipt of the replacement transaction (aTransactionReceipt)

Transactions are replaced when the user uses an option in their client to send a new transaction from the same account with the originalnonce. This is usually to speed up a transaction or to cancel one, by bribing miners with additional fees to prefer the new transaction over the original one.

transactionRequest.typenumber

TheEIP-2718 type of this transaction. If the transaction is a legacy transaction without an envelope, it will have the type0.

transactionRequest.accessListAccessList

TheAccessList included, or null for transaction types which do not support access lists.

TransactionReceipt

receipt.tostring<Address >

The address this transaction is to. This isnull if the transaction was aninit transaction, used to deploy a contract.

receipt.fromstring<Address >

The address this transaction is from.

receipt.contractAddressstring<Address >

If this transaction has anull to address, it is aninit transaction used to deploy a contract, in which case this is the address created by that contract.

To compute a contract address, thegetContractAddress utility function can also be used with aTransactionResponse object, which requires the transaction nonce and the address of the sender.

receipt.transactionIndexnumber

The index of this transaction in the list of transactions included in the block this transaction was mined in.

receipt.typenumber

TheEIP-2718 type of this transaction. If the transaction is a legacy transaction without an envelope, it will have the type0.

receipt.rootstring

The intermediate state root of a receipt.

Only transactions included in blocksbefore theByzantium Hard Fork have this property, as it was replaced by thestatus property.

The property is generally of little use to developers. At the time it could be used to verify a state transition with a fraud-proof only considering the single transaction; without it the full block must be considered.

receipt.gasUsedBigNumber

The amount of gas actually used by this transaction.

receipt.effectiveGasPriceBigNumber

The effective gas price the transaction was charged at.

Prior to EIP-1559 or on chains that do not support it, this value will simply be equal to the transactiongasPrice.

On EIP-1559 chains, this is equal to the blockbaseFee for the block that the transaction was included in, plus the transactionmaxPriorityFeePerGas clamped to the transactionmaxFeePerGas.

receipt.logsBloomstring<DataHexString >

Abloom-filter, which includes all the addresses and topics included in any log in this transaction.

receipt.blockHashstring<DataHexString< 32 > >

The block hash of the block that this transaction was included in.

receipt.transactionHashstring<DataHexString< 32 > >

The transaction hash of this transaction.

receipt.logsArray<Log >

All the logs emitted by this transaction.

receipt.blockNumbernumber

The block height (number) of the block that this transaction was included in.

receipt.confirmationsnumber

The number of blocks that have been mined since this transaction, including the actual block it was mined in.

receipt.cumulativeGasUsedBigNumber

For the block this transaction was included in, this is the sum of the gas used by each transaction in the ordered list of transactions up to (and including) this transaction.

This is generally of little interest to developers.

receipt.byzantiumboolean

This is true if the block is in apost-Byzantium Hard Fork block.

receipt.statusnumber

The status of a transaction is 1 is successful or 0 if it was reverted. Only transactions included in blockspost-Byzantium Hard Fork have this property.

Access Lists

An Access List is optional an includes a list of addresses and storage slots for that address which should bewarmed or pre-fetched for use within the execution of this transaction. Awarmed value has an additional upfront cost to access, but is discounted throughout the code execution for reading and writing.

AccessListish

A looser description of anAccessList, which will be converted internally usingaccessListify.

It may be any of:

When using the object form (the last option), the addresses and storage slots will be sorted. If an explicit order for the access list is required, one of the other forms must be used. Most developersdo not require explicit order.

equivalent to the AccessList example below
// Option 1:// AccessList// see below// Option 2:// Array< [ Address, Array<Bytes32> ] >accessList = [ [ "0x0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", [ "0x0000000000000000000000000000000000000000000000000000000000000004", "0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d" ] ], [ "0x5FfC014343cd971B7eb70732021E26C35B744cc4", [ "0x0000000000000000000000000000000000000000000000000000000000000001" ] ]];// Option 3:// Record<Address, Array<Bytes32>>accessList = { "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e": [ "0x0000000000000000000000000000000000000000000000000000000000000004", "0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d" ], "0x5FfC014343cd971B7eb70732021E26C35B744cc4": [ "0x0000000000000000000000000000000000000000000000000000000000000001" ]};

AccessList

AnEIP-2930 transaction allows an optionalAccessList which causes a transaction towarm (i.e. pre-cache) another addresses state and the specified storage keys.

This incurs an increased intrinsic cost for the transaction, but provides discounts for storage and state access throughout the execution of the transaction.

example access list
// Array of objects with the form:// {// address: Address,// storageKey: Array< DataHexString< 32 > >// }accessList = [ { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", storageKeys: [ "0x0000000000000000000000000000000000000000000000000000000000000004", "0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d" ] }, { address: "0x5FfC014343cd971B7eb70732021E26C35B744cc4", storageKeys: [ "0x0000000000000000000000000000000000000000000000000000000000000001" ] }];
Other Providers
Signers
The content of this site is licensed under theCreative Commons License. Generated on April 6, 2023, 1:54am.

[8]ページ先頭

©2009-2025 Movatter.jp