123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- 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";
- /**
- * A **TransactionLike** is an object which is appropriate as a loose
- * input for many operations which will populate missing properties of
- * a transaction.
- */
- 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;
- /**
- * The maximum fee per blob gas (see [[link-eip-4844]]).
- */
- maxFeePerBlobGas?: null | BigNumberish;
- /**
- * The versioned hashes (see [[link-eip-4844]]).
- */
- blobVersionedHashes?: null | Array<string>;
- /**
- * The blobs (if any) attached to this transaction (see [[link-eip-4844]]).
- */
- blobs?: null | Array<BlobLike>;
- /**
- * An external library for computing the KZG commitments and
- * proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
- *
- * This is generally ``null``, unless you are creating BLOb
- * transactions.
- */
- kzg?: null | KzgLibrary;
- }
- /**
- * A full-valid BLOb object for [[link-eip-4844]] transactions.
- *
- * The commitment and proof should have been computed using a
- * KZG library.
- */
- export interface Blob {
- data: string;
- proof: string;
- commitment: string;
- }
- /**
- * A BLOb object that can be passed for [[link-eip-4844]]
- * transactions.
- *
- * It may have had its commitment and proof already provided
- * or rely on an attached [[KzgLibrary]] to compute them.
- */
- export type BlobLike = BytesLike | {
- data: BytesLike;
- proof: BytesLike;
- commitment: BytesLike;
- };
- /**
- * A KZG Library with the necessary functions to compute
- * BLOb commitments and proofs.
- */
- export interface KzgLibrary {
- blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
- computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
- }
- /**
- * 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);
- /**
- * The amount of ether (in wei) to send in this transactions.
- */
- 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);
- /**
- * 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>);
- /**
- * The BLObs for the Transaction, if any.
- *
- * If ``blobs`` is non-``null``, then the [[seriailized]]
- * will return the network formatted sidecar, otherwise it
- * will return the standard [[link-eip-2718]] payload. The
- * [[unsignedSerialized]] is unaffected regardless.
- *
- * When setting ``blobs``, either fully valid [[Blob]] objects
- * may be specified (i.e. correctly padded, with correct
- * committments and proofs) or a raw [[BytesLike]] may
- * be provided.
- *
- * If raw [[BytesLike]] are provided, the [[kzg]] property **must**
- * be already set. The blob will be correctly padded and the
- * [[KzgLibrary]] will be used to compute the committment and
- * proof for the blob.
- *
- * A BLOb is a sequence of field elements, each of which must
- * be within the BLS field modulo, so some additional processing
- * may be required to encode arbitrary data to ensure each 32 byte
- * field is within the valid range.
- *
- * Setting this automatically populates [[blobVersionedHashes]],
- * overwriting any existing values. Setting this to ``null``
- * does **not** remove the [[blobVersionedHashes]], leaving them
- * present.
- */
- get blobs(): null | Array<Blob>;
- set blobs(_blobs: null | Array<BlobLike>);
- get kzg(): null | KzgLibrary;
- set kzg(kzg: null | KzgLibrary);
- /**
- * 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;
- });
- /**
- * 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>;
- });
- /**
- * 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;
- }
- //# sourceMappingURL=transaction.d.ts.map
|