ethers.js/lib.esm/transaction/transaction.d.ts

269 lines
7.3 KiB
TypeScript
Raw Normal View History

2022-09-05 23:57:11 +03:00
import { Signature } from "../crypto/index.js";
2022-11-30 23:44:23 +03:00
import type { BigNumberish, BytesLike } from "../utils/index.js";
2022-09-05 23:57:11 +03:00
import type { SignatureLike } from "../crypto/index.js";
import type { AccessList, AccessListish } from "./index.js";
2023-06-02 00:52:58 +03:00
/**
* A **TransactionLike** is an object which is appropriate as a loose
* input for many operations which will populate missing properties of
* a transaction.
*/
2022-09-05 23:57:11 +03:00
export interface TransactionLike<A = string> {
2022-12-03 05:27:06 +03:00
/**
* The type.
*/
2022-09-05 23:57:11 +03:00
type?: null | number;
2022-12-03 05:27:06 +03:00
/**
* The recipient address or ``null`` for an ``init`` transaction.
*/
2022-09-05 23:57:11 +03:00
to?: null | A;
2022-12-03 05:27:06 +03:00
/**
* The sender.
*/
2022-09-05 23:57:11 +03:00
from?: null | A;
2022-12-03 05:27:06 +03:00
/**
* The nonce.
*/
2022-09-05 23:57:11 +03:00
nonce?: null | number;
2022-12-03 05:27:06 +03:00
/**
* The maximum amount of gas that can be used.
*/
2022-09-05 23:57:11 +03:00
gasLimit?: null | BigNumberish;
2022-12-03 05:27:06 +03:00
/**
* The gas price for legacy and berlin transactions.
*/
2022-09-05 23:57:11 +03:00
gasPrice?: null | BigNumberish;
2022-12-03 05:27:06 +03:00
/**
* The maximum priority fee per gas for london transactions.
*/
2022-09-05 23:57:11 +03:00
maxPriorityFeePerGas?: null | BigNumberish;
2022-12-03 05:27:06 +03:00
/**
* The maximum total fee per gas for london transactions.
*/
2022-09-05 23:57:11 +03:00
maxFeePerGas?: null | BigNumberish;
2022-12-03 05:27:06 +03:00
/**
* The data.
*/
2022-09-05 23:57:11 +03:00
data?: null | string;
2022-12-03 05:27:06 +03:00
/**
* The value (in wei) to send.
*/
2022-09-05 23:57:11 +03:00
value?: null | BigNumberish;
2022-12-03 05:27:06 +03:00
/**
* The chain ID the transaction is valid on.
*/
2022-09-05 23:57:11 +03:00
chainId?: null | BigNumberish;
2022-12-03 05:27:06 +03:00
/**
* The transaction hash.
*/
2022-09-05 23:57:11 +03:00
hash?: null | string;
2022-12-03 05:27:06 +03:00
/**
* The signature provided by the sender.
*/
2022-09-05 23:57:11 +03:00
signature?: null | SignatureLike;
2022-12-03 05:27:06 +03:00
/**
* The access list for berlin and london transactions.
*/
2022-09-05 23:57:11 +03:00
accessList?: null | AccessListish;
}
2022-12-03 05:27:06 +03: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.
2022-12-10 02:24:58 +03:00
*
* @example:
* tx = new Transaction()
* //_result:
*
* tx.data = "0x1234";
* //_result:
2022-12-03 05:27:06 +03:00
*/
2022-11-30 23:44:23 +03:00
export declare class Transaction implements TransactionLike<string> {
2022-09-05 23:57:11 +03:00
#private;
2022-12-03 05:27:06 +03:00
/**
* The transaction type.
*
* If null, the type will be automatically inferred based on
* explicit properties.
*/
2022-09-05 23:57:11 +03:00
get type(): null | number;
set type(value: null | number | string);
2022-12-03 05:27:06 +03:00
/**
* 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.
*/
2022-09-05 23:57:11 +03:00
get to(): null | string;
set to(value: null | string);
2022-12-03 05:27:06 +03:00
/**
* The transaction nonce.
*/
2022-09-05 23:57:11 +03:00
get nonce(): number;
set nonce(value: BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* The gas limit.
*/
2022-09-05 23:57:11 +03:00
get gasLimit(): bigint;
set gasLimit(value: BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* The gas price.
*
* On legacy networks this defines the fee that will be paid. On
* EIP-1559 networks, this should be ``null``.
*/
2022-09-05 23:57:11 +03:00
get gasPrice(): null | bigint;
set gasPrice(value: null | BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* The maximum priority fee per unit of gas to pay. On legacy
* networks this should be ``null``.
*/
2022-09-05 23:57:11 +03:00
get maxPriorityFeePerGas(): null | bigint;
set maxPriorityFeePerGas(value: null | BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* The maximum total fee per unit of gas to pay. On legacy
* networks this should be ``null``.
*/
2022-09-05 23:57:11 +03:00
get maxFeePerGas(): null | bigint;
set maxFeePerGas(value: null | BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* The transaction data. For ``init`` transactions this is the
* deployment code.
*/
2022-09-05 23:57:11 +03:00
get data(): string;
set data(value: BytesLike);
2022-12-03 05:27:06 +03:00
/**
2023-04-25 14:04:48 +03:00
* The amount of ether (in wei) to send in this transactions.
2022-12-03 05:27:06 +03:00
*/
2022-09-05 23:57:11 +03:00
get value(): bigint;
set value(value: BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* The chain ID this transaction is valid on.
*/
2022-09-05 23:57:11 +03:00
get chainId(): bigint;
set chainId(value: BigNumberish);
2022-12-03 05:27:06 +03:00
/**
* If signed, the signature for this transaction.
*/
2022-09-05 23:57:11 +03:00
get signature(): null | Signature;
set signature(value: null | SignatureLike);
2022-12-03 05:27:06 +03:00
/**
* The access list.
*
* An access list permits discounted (but pre-paid) access to
* bytecode and state variable access within contract execution.
*/
2022-09-05 23:57:11 +03:00
get accessList(): null | AccessList;
set accessList(value: null | AccessListish);
2022-12-03 05:27:06 +03:00
/**
* Creates a new Transaction with default values.
*/
2022-09-05 23:57:11 +03:00
constructor();
2022-12-03 05:27:06 +03:00
/**
* The transaction hash, if signed. Otherwise, ``null``.
*/
2022-09-05 23:57:11 +03:00
get hash(): null | string;
2022-12-03 05:27:06 +03:00
/**
* The pre-image hash of this transaction.
*
* This is the digest that a [[Signer]] must sign to authorize
* this transaction.
*/
2022-09-05 23:57:11 +03:00
get unsignedHash(): string;
2022-12-03 05:27:06 +03:00
/**
* The sending address, if signed. Otherwise, ``null``.
*/
2022-09-05 23:57:11 +03:00
get from(): null | string;
2022-12-03 05:27:06 +03:00
/**
* The public key of the sender, if signed. Otherwise, ``null``.
*/
2022-09-05 23:57:11 +03:00
get fromPublicKey(): null | string;
2022-12-03 05:27:06 +03:00
/**
* 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]].
*/
2022-09-05 23:57:11 +03:00
get serialized(): string;
2022-12-03 05:27:06 +03:00
/**
* The transaction pre-image.
*
* The hash of this is the digest which needs to be signed to
* authorize this transaction.
*/
2022-09-05 23:57:11 +03:00
get unsignedSerialized(): string;
2022-11-30 23:44:23 +03:00
/**
* Return the most "likely" type; currently the highest
2022-12-03 05:27:06 +03:00
* supported transaction type.
2022-11-30 23:44:23 +03:00
*/
inferType(): number;
2022-12-03 05:27:06 +03:00
/**
* Validates the explicit properties and returns a list of compatible
* transaction types.
*/
2022-09-05 23:57:11 +03:00
inferTypes(): Array<number>;
2022-12-03 05:27:06 +03:00
/**
* 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.
*/
2022-09-16 05:58:45 +03:00
isLegacy(): this is (Transaction & {
type: 0;
gasPrice: bigint;
});
2022-12-03 05:27:06 +03:00
/**
* 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.
*/
2022-09-16 05:58:45 +03:00
isBerlin(): this is (Transaction & {
type: 1;
gasPrice: bigint;
accessList: AccessList;
});
2022-12-03 05:27:06 +03:00
/**
* 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.
*/
2022-09-16 05:58:45 +03:00
isLondon(): this is (Transaction & {
type: 2;
accessList: AccessList;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
});
2022-12-03 05:27:06 +03:00
/**
* Create a copy of this transaciton.
*/
2022-09-05 23:57:11 +03:00
clone(): Transaction;
2022-12-03 05:27:06 +03:00
/**
* Return a JSON-friendly object.
*/
2022-10-20 12:03:32 +03:00
toJSON(): any;
2022-12-03 05:27:06 +03:00
/**
* Create a **Transaction** from a serialized transaction or a
* Transaction-like object.
*/
static from(tx?: string | TransactionLike<string>): Transaction;
2022-09-05 23:57:11 +03:00
}
//# sourceMappingURL=transaction.d.ts.map