UNPKG

js-conflux-sdk

Version:
147 lines 5.53 kB
export = Transaction; /** * @typedef {import('./rpc/types/formatter').CallRequest} TransactionMeta */ declare class Transaction { /** * Decode rlp encoded raw transaction hex string * @param {string} raw - rlp encoded transaction hex string * @returns {Transaction} A Transaction instance */ static decodeRaw(raw: string): Transaction; static formatTxMeta({ nonce, gas, to, value, storageLimit, epochHeight, chainId, data, r, s, v }: { nonce: any; gas: any; to: any; value: any; storageLimit: any; epochHeight: any; chainId: any; data: any; r: any; s: any; v: any; }): { nonce: any; gas: any; to: any; value: any; storageLimit: any; epochHeight: any; chainId: any; data: any; v: any; r: any; s: any; }; static decodeLegacy(raw: any): import("./Transaction"); static decode2930(raw: any): import("./Transaction"); static decode1559(raw: any): import("./Transaction"); /** * Create a transaction. * * @param {object} options * @param {number} [options.type] - Tx type: 0 for legacy, 1 for EIP-2930, 2 for EIP-1559 * @param {string} [options.from] - The sender address. * @param {string|number} [options.nonce] - This allows to overwrite your own pending transactions that use the same nonce. * @param {string|number} [options.gasPrice] - The price of gas for this transaction in drip. * @param {string|number} [options.gas]- The amount of gas to use for the transaction (unused gas is refunded). * @param {string} [options.to] - The destination address of the message, left undefined for a contract-creation transaction. * @param {string|number} [options.value] - The value transferred for the transaction in drip, also the endowment if it’s a contract-creation transaction. * @param {string|number} [options.storageLimit] - The storage limit specified by the sender. * @param {string|number} [options.epochHeight] - The epoch proposed by the sender. Note that this is NOT the epoch of the block containing this transaction. * @param {string|number} [options.chainId] - The chain ID specified by the sender. * @param {string|Buffer} [options.data]- Either a ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialisation code. * @param {string|Buffer} [options.r] - ECDSA signature r * @param {string|Buffer} [options.s] - ECDSA signature s * @param {number} [options.v] - ECDSA signature v * @param {array} [options.accessList] - EIP-2930 access list * @param {string|number} [options.maxPriorityFeePerGas] - EIP-1559 maxPriorityFeePerGas * @param {string|number} [options.maxFeePerGas] - EIP-1559 maxFeePerGas * @return {Transaction} */ constructor({ type, from, nonce, gasPrice, gas, to, value, storageLimit, epochHeight, chainId, data, v, r, s, accessList, maxPriorityFeePerGas, maxFeePerGas, }: { type?: number; from?: string; nonce?: string | number; gasPrice?: string | number; gas?: string | number; to?: string; value?: string | number; storageLimit?: string | number; epochHeight?: string | number; chainId?: string | number; data?: string | Buffer; r?: string | Buffer; s?: string | Buffer; v?: number; accessList?: any[]; maxPriorityFeePerGas?: string | number; maxFeePerGas?: string | number; }); type: number; from: string; nonce: string | number; gasPrice: string | number; gas: string | number; to: string; value: string | number; storageLimit: string | number; epochHeight: string | number; chainId: string | number; data: string | Buffer; v: number; r: string | Buffer; s: string | Buffer; accessList: AccessList; maxPriorityFeePerGas: string | number; maxFeePerGas: string | number; /** * Getter of transaction hash include signature. * * > Note: calculate every time. * * @return {string|undefined} If transaction has r,s,v return hex string, else return undefined. */ get hash(): string; /** * Sign transaction and set 'r','s','v'. * * @param {string} privateKey - Private key hex string. * @param {number} networkId - fullnode's network id. * @return {Transaction} */ sign(privateKey: string, networkId: number): Transaction; /** * Recover public key from signed Transaction. * * @return {string} */ recover(): string; /** * Infer the transaction type from the fields. * @returns {number} Transaction type */ txType(): number; typePrefix(): Buffer; encodeAccessList(): any[]; /** * Encode rlp. * * @param {boolean} [includeSignature=false] - Whether or not to include the signature. * @return {Buffer} */ encode(includeSignature?: boolean): Buffer; /** * Get the raw transaction hex string. * * @return {string} Hex string */ serialize(): string; } declare namespace Transaction { export { TransactionMeta }; } import { AccessList } from "./primitives/AccessList"; type TransactionMeta = import('./rpc/types/formatter').CallRequest; //# sourceMappingURL=Transaction.d.ts.map