2023-03-03 18:25:07 -07:00
|
|
|
import { Signature } from "../crypto/index.js";
|
|
|
|
import type { BigNumberish, BytesLike } from "../utils/index.js";
|
|
|
|
import type { SignatureLike } from "../crypto/index.js";
|
|
|
|
import type { AccessList, AccessListish } from "./index.js";
|
2023-06-01 17:52:58 -04:00
|
|
|
/**
|
|
|
|
* A **TransactionLike** is an object which is appropriate as a loose
|
|
|
|
* input for many operations which will populate missing properties of
|
|
|
|
* a transaction.
|
|
|
|
*/
|
2023-03-03 18:25:07 -07:00
|
|
|
export interface TransactionLike<A = string> {
|
|
|
|
/**
|
|
|
|
* The type.
|
|
|
|
*/
|
|
|
|
type?: null | number;
|
|
|
|
/**
|
|
|
|
* The recipient address or ``null`` for an ``init`` transaction.
|
|
|
|
*/
|
|
|
|
to?: null | A;
|
|
|
|
/**
|
|
|
|
* The sender.
|
|
|
|
*/
|
|
|
|
from?: null | A;
|
|
|
|
/**
|
|
|
|
* The nonce.
|
|
|
|
*/
|
|
|
|
nonce?: null | number;
|
|
|
|
/**
|
|
|
|
* The maximum amount of gas that can be used.
|
|
|
|
*/
|
|
|
|
gasLimit?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The gas price for legacy and berlin transactions.
|
|
|
|
*/
|
|
|
|
gasPrice?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The maximum priority fee per gas for london transactions.
|
|
|
|
*/
|
|
|
|
maxPriorityFeePerGas?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The maximum total fee per gas for london transactions.
|
|
|
|
*/
|
|
|
|
maxFeePerGas?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The data.
|
|
|
|
*/
|
|
|
|
data?: null | string;
|
|
|
|
/**
|
|
|
|
* The value (in wei) to send.
|
|
|
|
*/
|
|
|
|
value?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The chain ID the transaction is valid on.
|
|
|
|
*/
|
|
|
|
chainId?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The transaction hash.
|
|
|
|
*/
|
|
|
|
hash?: null | string;
|
|
|
|
/**
|
|
|
|
* The signature provided by the sender.
|
|
|
|
*/
|
|
|
|
signature?: null | SignatureLike;
|
|
|
|
/**
|
|
|
|
* The access list for berlin and london transactions.
|
|
|
|
*/
|
|
|
|
accessList?: null | AccessListish;
|
2024-02-02 03:25:03 -05:00
|
|
|
/**
|
|
|
|
* The maximum fee per blob gas (see [[link-eip-4844]]).
|
|
|
|
*/
|
|
|
|
maxFeePerBlobGas?: null | BigNumberish;
|
|
|
|
/**
|
|
|
|
* The versioned hashes (see [[link-eip-4844]]).
|
|
|
|
*/
|
|
|
|
blobVersionedHashes?: null | Array<string>;
|
2023-03-03 18:25:07 -07:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* A **Transaction** describes an operation to be executed on
|
|
|
|
* Ethereum by an Externally Owned Account (EOA). It includes
|
|
|
|
* who (the [[to]] address), what (the [[data]]) and how much (the
|
|
|
|
* [[value]] in ether) the operation should entail.
|
|
|
|
*
|
|
|
|
* @example:
|
|
|
|
* tx = new Transaction()
|
|
|
|
* //_result:
|
|
|
|
*
|
|
|
|
* tx.data = "0x1234";
|
|
|
|
* //_result:
|
|
|
|
*/
|
|
|
|
export declare class Transaction implements TransactionLike<string> {
|
|
|
|
#private;
|
|
|
|
/**
|
|
|
|
* The transaction type.
|
|
|
|
*
|
|
|
|
* If null, the type will be automatically inferred based on
|
|
|
|
* explicit properties.
|
|
|
|
*/
|
|
|
|
get type(): null | number;
|
|
|
|
set type(value: null | number | string);
|
|
|
|
/**
|
|
|
|
* The name of the transaction type.
|
|
|
|
*/
|
|
|
|
get typeName(): null | string;
|
|
|
|
/**
|
|
|
|
* The ``to`` address for the transaction or ``null`` if the
|
|
|
|
* transaction is an ``init`` transaction.
|
|
|
|
*/
|
|
|
|
get to(): null | string;
|
|
|
|
set to(value: null | string);
|
|
|
|
/**
|
|
|
|
* The transaction nonce.
|
|
|
|
*/
|
|
|
|
get nonce(): number;
|
|
|
|
set nonce(value: BigNumberish);
|
|
|
|
/**
|
|
|
|
* The gas limit.
|
|
|
|
*/
|
|
|
|
get gasLimit(): bigint;
|
|
|
|
set gasLimit(value: BigNumberish);
|
|
|
|
/**
|
|
|
|
* The gas price.
|
|
|
|
*
|
|
|
|
* On legacy networks this defines the fee that will be paid. On
|
|
|
|
* EIP-1559 networks, this should be ``null``.
|
|
|
|
*/
|
|
|
|
get gasPrice(): null | bigint;
|
|
|
|
set gasPrice(value: null | BigNumberish);
|
|
|
|
/**
|
|
|
|
* The maximum priority fee per unit of gas to pay. On legacy
|
|
|
|
* networks this should be ``null``.
|
|
|
|
*/
|
|
|
|
get maxPriorityFeePerGas(): null | bigint;
|
|
|
|
set maxPriorityFeePerGas(value: null | BigNumberish);
|
|
|
|
/**
|
|
|
|
* The maximum total fee per unit of gas to pay. On legacy
|
|
|
|
* networks this should be ``null``.
|
|
|
|
*/
|
|
|
|
get maxFeePerGas(): null | bigint;
|
|
|
|
set maxFeePerGas(value: null | BigNumberish);
|
|
|
|
/**
|
|
|
|
* The transaction data. For ``init`` transactions this is the
|
|
|
|
* deployment code.
|
|
|
|
*/
|
|
|
|
get data(): string;
|
|
|
|
set data(value: BytesLike);
|
|
|
|
/**
|
2023-04-25 20:04:48 +09:00
|
|
|
* The amount of ether (in wei) to send in this transactions.
|
2023-03-03 18:25:07 -07:00
|
|
|
*/
|
|
|
|
get value(): bigint;
|
|
|
|
set value(value: BigNumberish);
|
|
|
|
/**
|
|
|
|
* The chain ID this transaction is valid on.
|
|
|
|
*/
|
|
|
|
get chainId(): bigint;
|
|
|
|
set chainId(value: BigNumberish);
|
|
|
|
/**
|
|
|
|
* If signed, the signature for this transaction.
|
|
|
|
*/
|
|
|
|
get signature(): null | Signature;
|
|
|
|
set signature(value: null | SignatureLike);
|
|
|
|
/**
|
|
|
|
* The access list.
|
|
|
|
*
|
|
|
|
* An access list permits discounted (but pre-paid) access to
|
|
|
|
* bytecode and state variable access within contract execution.
|
|
|
|
*/
|
|
|
|
get accessList(): null | AccessList;
|
|
|
|
set accessList(value: null | AccessListish);
|
2024-02-02 03:25:03 -05:00
|
|
|
/**
|
|
|
|
* The max fee per blob gas for Cancun transactions.
|
|
|
|
*/
|
|
|
|
get maxFeePerBlobGas(): null | bigint;
|
|
|
|
set maxFeePerBlobGas(value: null | BigNumberish);
|
|
|
|
/**
|
|
|
|
* The BLOB versioned hashes for Cancun transactions.
|
|
|
|
*/
|
|
|
|
get blobVersionedHashes(): null | Array<string>;
|
|
|
|
set blobVersionedHashes(value: null | Array<string>);
|
2023-03-03 18:25:07 -07:00
|
|
|
/**
|
|
|
|
* Creates a new Transaction with default values.
|
|
|
|
*/
|
|
|
|
constructor();
|
|
|
|
/**
|
|
|
|
* The transaction hash, if signed. Otherwise, ``null``.
|
|
|
|
*/
|
|
|
|
get hash(): null | string;
|
|
|
|
/**
|
|
|
|
* The pre-image hash of this transaction.
|
|
|
|
*
|
|
|
|
* This is the digest that a [[Signer]] must sign to authorize
|
|
|
|
* this transaction.
|
|
|
|
*/
|
|
|
|
get unsignedHash(): string;
|
|
|
|
/**
|
|
|
|
* The sending address, if signed. Otherwise, ``null``.
|
|
|
|
*/
|
|
|
|
get from(): null | string;
|
|
|
|
/**
|
|
|
|
* The public key of the sender, if signed. Otherwise, ``null``.
|
|
|
|
*/
|
|
|
|
get fromPublicKey(): null | string;
|
|
|
|
/**
|
|
|
|
* Returns true if signed.
|
|
|
|
*
|
|
|
|
* This provides a Type Guard that properties requiring a signed
|
|
|
|
* transaction are non-null.
|
|
|
|
*/
|
|
|
|
isSigned(): this is (Transaction & {
|
|
|
|
type: number;
|
|
|
|
typeName: string;
|
|
|
|
from: string;
|
|
|
|
signature: Signature;
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* The serialized transaction.
|
|
|
|
*
|
|
|
|
* This throws if the transaction is unsigned. For the pre-image,
|
|
|
|
* use [[unsignedSerialized]].
|
|
|
|
*/
|
|
|
|
get serialized(): string;
|
|
|
|
/**
|
|
|
|
* The transaction pre-image.
|
|
|
|
*
|
|
|
|
* The hash of this is the digest which needs to be signed to
|
|
|
|
* authorize this transaction.
|
|
|
|
*/
|
|
|
|
get unsignedSerialized(): string;
|
|
|
|
/**
|
|
|
|
* Return the most "likely" type; currently the highest
|
|
|
|
* supported transaction type.
|
|
|
|
*/
|
|
|
|
inferType(): number;
|
|
|
|
/**
|
|
|
|
* Validates the explicit properties and returns a list of compatible
|
|
|
|
* transaction types.
|
|
|
|
*/
|
|
|
|
inferTypes(): Array<number>;
|
|
|
|
/**
|
|
|
|
* Returns true if this transaction is a legacy transaction (i.e.
|
|
|
|
* ``type === 0``).
|
|
|
|
*
|
|
|
|
* This provides a Type Guard that the related properties are
|
|
|
|
* non-null.
|
|
|
|
*/
|
|
|
|
isLegacy(): this is (Transaction & {
|
|
|
|
type: 0;
|
|
|
|
gasPrice: bigint;
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* Returns true if this transaction is berlin hardform transaction (i.e.
|
|
|
|
* ``type === 1``).
|
|
|
|
*
|
|
|
|
* This provides a Type Guard that the related properties are
|
|
|
|
* non-null.
|
|
|
|
*/
|
|
|
|
isBerlin(): this is (Transaction & {
|
|
|
|
type: 1;
|
|
|
|
gasPrice: bigint;
|
|
|
|
accessList: AccessList;
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* Returns true if this transaction is london hardform transaction (i.e.
|
|
|
|
* ``type === 2``).
|
|
|
|
*
|
|
|
|
* This provides a Type Guard that the related properties are
|
|
|
|
* non-null.
|
|
|
|
*/
|
|
|
|
isLondon(): this is (Transaction & {
|
|
|
|
type: 2;
|
|
|
|
accessList: AccessList;
|
|
|
|
maxFeePerGas: bigint;
|
|
|
|
maxPriorityFeePerGas: bigint;
|
|
|
|
});
|
2024-02-02 03:25:03 -05:00
|
|
|
/**
|
|
|
|
* Returns true if this transaction is an [[link-eip-4844]] BLOB
|
|
|
|
* transaction.
|
|
|
|
*
|
|
|
|
* This provides a Type Guard that the related properties are
|
|
|
|
* non-null.
|
|
|
|
*/
|
|
|
|
isCancun(): this is (Transaction & {
|
|
|
|
type: 3;
|
|
|
|
to: string;
|
|
|
|
accessList: AccessList;
|
|
|
|
maxFeePerGas: bigint;
|
|
|
|
maxPriorityFeePerGas: bigint;
|
|
|
|
maxFeePerBlobGas: bigint;
|
|
|
|
blobVersionedHashes: Array<string>;
|
|
|
|
});
|
2023-03-03 18:25:07 -07:00
|
|
|
/**
|
|
|
|
* Create a copy of this transaciton.
|
|
|
|
*/
|
|
|
|
clone(): Transaction;
|
|
|
|
/**
|
|
|
|
* Return a JSON-friendly object.
|
|
|
|
*/
|
|
|
|
toJSON(): any;
|
|
|
|
/**
|
|
|
|
* Create a **Transaction** from a serialized transaction or a
|
|
|
|
* Transaction-like object.
|
|
|
|
*/
|
|
|
|
static from(tx?: string | TransactionLike<string>): Transaction;
|
|
|
|
}
|
2023-04-27 21:19:55 +09:00
|
|
|
//# sourceMappingURL=transaction.d.ts.map
|