Protected
constructorCreates a new instance of the class with the specified transaction body and optional signature.
The transaction body to be used.
Optional
signature: Uint8ArrayThe optional signature for the transaction.
Readonly
bodyIt represents the content of the transaction.
Optional
Readonly
signatureIt represents the signature of the transaction content.
Readonly
transactionIt represents the type of the transaction.
Static
Readonly
GAS_A collection of constants used for gas calculations in transactions.
Properties
TX_GAS
- The base gas cost for a transaction.CLAUSE_GAS
- The gas cost for executing a clause in a transaction.CLAUSE_GAS_CONTRACT_CREATION
- The gas cost for creating a contract via a clause.ZERO_GAS_DATA
- The gas cost for transmitting zero bytes of data.NON_ZERO_GAS_DATA
- The gas cost for transmitting non-zero bytes of data.Get the encoded bytes as a Uint8Array. The encoding is determined by whether the data is signed.
The encoded byte array.
Get the gas payer's address if the transaction is delegated.
If the transaction is delegated and a signature is available, this method recovers the gas payer parameter from the signature and subsequently recovers the gas payer's public key to derive the gas payer's address.
The address of the gas payer.
Get transaction ID.
The ID is the Blake2b256 hash of the transaction's signature concatenated with the origin's address. If the transaction is not signed, it throws an UnavailableTransactionField error.
The concatenated hash of the signature and origin if the transaction is signed.
Returns true
if the transaction is delegated, otherwise false
.
true
if the transaction is delegated,
otherwise false
.
Return true
if the signature is defined and complete, otherwise false
.
return true
if the signature is defined and complete, otherwise false
.
Any delegated transaction signed with signAsSender but not yet signed with signAsGasPayer is not signed.
Computes the transaction hash, optionally incorporating a gas payer's address.
Optional
sender: AddressOptional transaction origin's address to include in the hash computation.
Signs the transaction using the provided private key of the transaction sender.
The private key used to sign the transaction.
The signed transaction.
Signs a transaction as a gas payer using the provided private key. This is applicable only if the transaction has been marked as delegated and already contains the signature of the transaction sender that needs to be extended with the gas payer's signature.
The address of the sender for whom the transaction hash is generated.
The private key of the gas payer. Must be a valid secp256k1 key.
Signs a delegated transaction using the provided transaction sender's private key,
call the signAsGasPayer to complete the signature,
before such call isDelegated returns true
but
isSigned returns false
.
The private key of the transaction sender, represented as a Uint8Array. It must be a valid secp256k1 private key.
A new Transaction object with the signature applied, if the transaction is delegated and the private key is valid.
Signs the transaction using both the transaction sender and the gas payer private keys.
The private key of the transaction sender.
The private key of the gas payer.
A new transaction with the concatenated signatures of the transaction sender and the gas payer.
Static
decodeDecodes a raw transaction byte array into a new Transaction object.
The raw transaction bytes to decode.
Flag indicating if the transaction is signed.
The decoded transaction object.
Static
intrinsicCalculates the intrinsic gas required for the given transaction clauses.
An array of transaction clauses to calculate the intrinsic gas for.
The total intrinsic gas required for the provided clauses.
Static
isValidates the transaction body's fields according to the transaction type.
The transaction body to validate.
The transaction type to validate the body against.
True if the transaction body is valid for the given type.
Static
ofCreates a new Transaction instance if the provided body is valid.
The transaction body to be validated.
Optional
signature: Uint8ArrayOptional signature.
A new Transaction instance if validation is successful.
Represents an immutable transaction entity.