ethers.js/docs.wrm/api/utils/transactions.wrm

146 lines
5.8 KiB
Plaintext
Raw Permalink Normal View History

2020-05-08 03:24:40 -04:00
_section: Transactions @<transactions>
2020-02-01 03:39:21 -05:00
2020-06-12 03:38:55 -04:00
_subsection: Types @<transactions--types>
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_heading: UnsignedTransaction @<UnsignedTransaction>
2020-02-17 17:56:13 -05:00
An unsigned transaction represents a transaction that has not been
signed and its values are flexible as long as they are not ambiguous.
2020-02-01 03:39:21 -05:00
_property: unsignedTransaction.to => string<[Address](address)>
2020-11-22 23:03:50 -05:00
The address this transaction is to.
2020-02-01 03:39:21 -05:00
_property: unsignedTransaction.nonce => number
2020-02-17 17:56:13 -05:00
The nonce of this transaction.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: unsignedTransaction.gasLimit => [[BigNumberish]]
2020-02-17 17:56:13 -05:00
The gas limit for this transaction.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: unsignedTransaction.gasPrice => [[BigNumberish]]
2020-02-17 17:56:13 -05:00
The gas price for this transaction.
2020-02-01 03:39:21 -05:00
_property: unsignedTransaction.maxFeePerGas => [[BigNumberish]]
The maximum fee per unit of gas for this transaction.
_property: unsignedTransaction.maxPriorityFeePerGas => [[BigNumberish]]
The maximum priority fee per unit of gas for this transaction.
2020-05-08 03:24:40 -04:00
_property: unsignedTransaction.data => [[BytesLike]]
2020-02-17 17:56:13 -05:00
The data for this transaction.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: unsignedTransaction.value => [[BigNumberish]]
2020-02-17 17:56:13 -05:00
The value (in wei) for this transaction.
2020-02-01 03:39:21 -05:00
_property: unsignedTransaction.chainId => number
2020-02-17 17:56:13 -05:00
The chain ID for this transaction. If the chain ID is 0 or null,
then [[link-eip-155]] is disabled and legacy signing is
used, unless overridden in a signature.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_heading: Transaction @<Transaction>
2020-02-01 03:39:21 -05:00
A generic object to represent a transaction.
2020-05-08 03:24:40 -04:00
_property: transaction.hash => string<[[DataHexString]]<32>>
2020-02-17 17:56:13 -05:00
The transaction hash, which can be used as an identifier for
//transaction//. This is the keccak256 of the serialized RLP encoded
representation of //transaction//.
2020-02-01 03:39:21 -05:00
_property: transaction.to => string<[Address](address)>
2020-02-17 17:56:13 -05:00
The address //transaction// is to.
2020-02-01 03:39:21 -05:00
2020-02-17 17:56:13 -05:00
_property: transaction.from => string<[Address](address)>
The address //transaction// is from.
2020-02-01 03:39:21 -05:00
2020-02-17 17:56:13 -05:00
_property: transaction.nonce => number
The nonce for //transaction//. Each transaction sent to the network
from an account includes this, which ensures the order and
non-replayability of a transaction. This must be equal to the current
number of transactions ever sent to the network by the **from** address.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: transaction.gasLimit => [[BigNumber]]
2020-02-17 17:56:13 -05:00
The gas limit for //transaction//. An account must have enough ether to
cover the gas (at the specified **gasPrice**). Any unused gas is
refunded at the end of the transaction, and if there is insufficient gas
2020-10-03 13:30:15 -03:00
to complete execution, the effects of the transaction are reverted, but
2020-02-17 17:56:13 -05:00
the gas is **fully consumed** and an out-of-gas error occurs.
2020-02-01 03:39:21 -05:00
_property: transaction.gasPrice => null | [[BigNumber]]
2020-02-17 17:56:13 -05:00
The price (in wei) per unit of gas for //transaction//.
2020-02-01 03:39:21 -05:00
For [[link-eip-1559]] transactions, this will be null.
_property: transaction.maxFeePerGas => [[BigNumber]]
The maximum price (in wei) per unit of gas for //transaction//.
For transactions that are not [[link-eip-1559]] transactions, this will be null.
_property: transaction.maxPriorityFeePerGas => [[BigNumber]]
The priority fee price (in wei) per unit of gas for //transaction//.
For transactions that are not [[link-eip-1559]] transactions, this will be null.
2020-05-08 03:24:40 -04:00
_property: transaction.data => [[BytesLike]]
2020-02-17 17:56:13 -05:00
The data for //transaction//. In a contract this is the call data.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: transaction.value => [[BigNumber]]
2020-02-17 17:56:13 -05:00
The value (in wei) for //transaction//.
2020-02-01 03:39:21 -05:00
2020-02-17 17:56:13 -05:00
_property: transaction.chainId => number
The chain ID for //transaction//. This is used as part of
[[link-eip-155]] to prevent replay attacks on different
networks.
For example, if a transaction was made on ropsten with an account
also used on homestead, it would be possible for a transaction
signed on ropsten to be executed on homestead, which is likely
unintended.
2020-02-01 03:39:21 -05:00
2020-02-17 17:56:13 -05:00
There are situations where replay may be desired, however these
are very rare and it is almost always recommended to specify the
chain ID.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: transaction.r => string<[[DataHexString]]<32>>
2020-02-17 17:56:13 -05:00
The r portion of the elliptic curve signatures for //transaction//.
This is more accurately, the x coordinate of the point r (from
which the y can be computed, along with v).
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: transaction.s => string<[[DataHexString]]<32>>
2020-02-17 17:56:13 -05:00
The s portion of the elliptic curve signatures for //transaction//.
_property: transaction.v => number
The v portion of the elliptic curve signatures for //transaction//.
This is used to refine which of the two possible points a given
x-coordinate can have, and in [[link-eip-155]] is additionally
used to encode the chain ID into the serialized transaction.
2020-02-01 03:39:21 -05:00
2020-06-12 03:38:55 -04:00
_subsection: Functions @<transactions--functions>
2020-02-01 03:39:21 -05:00
_property: ethers.utils.accessListify(anAcceslistish) => [[providers-AccessList]] @<utils-accessListify> @SRC<transactions:accessListify>
Normalizes the [[providers-AccessListish]] //anAccessListish// into
an [[providers-AccessList]].
This is useful for other utility functions which wish to remain
flexible as to the input parameter for access lists, such as
when creating a [[Signer]] which needs to manipulate a possibly
typed transaction envelope.
2020-05-08 03:24:40 -04:00
_property: ethers.utils.parseTransaction(aBytesLike) => [[Transaction]] @<utils-parseTransaction> @SRC<transactions:parse>
2020-11-22 23:03:50 -05:00
Parses the transaction properties from a serialized transaction.
2020-02-01 03:39:21 -05:00
2020-05-08 03:24:40 -04:00
_property: ethers.utils.serializeTransaction(tx [ , signature ]) => string<[[DataHexString]]> @<utils-serializeTransaction> @SRC<transactions:serialize>
2020-02-17 17:56:13 -05:00
Computes the serialized //transaction//, optionally serialized with
the a //signature//. If //signature// is not present, the unsigned
serialized transaction is returned, which can be used to compute the
hash necessary to sign.
This function uses [[link-eip-155]] if a chainId is provided,
otherwise legacy serialization is used. It is **highly** recommended
to always specify a //chainId//.
If //signature// includes a chain ID (explicitly or implicitly by using an
[[link-eip-155]] ``v`` or ``_vs``) it will be used to compute the
chain ID.
2020-02-01 03:39:21 -05:00
2020-02-17 17:56:13 -05:00
If there is a mismatch between the chain ID of //transaction// and //signature//
an error is thrown.