toSerializableTransaction

Converts a prepared transaction to a transaction with populated options.

Example

import {
prepareTransaction,
toSerializableTransaction,
} from "thirdweb";
const transaction = await prepareTransaction({
transaction: {
to: "0x...",
value: 100,
},
});
const finalTx = await toSerializableTransaction({
transaction,
});
account.sendTransaction(finalTx);
function toSerializableTransaction(
): Promise<
| {
accessList: undefined | AccessList;
chainId: number;
data: `0x${string}`;
gas: bigint;
gasPrice?: undefined;
maxFeePerGas?: bigint;
maxPriorityFeePerGas?: bigint;
nonce: undefined | number;
to: undefined | string;
value: undefined | bigint;
}
| {
accessList: undefined | AccessList;
chainId: number;
data: `0x${string}`;
gas: bigint;
gasPrice?: bigint;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
nonce: undefined | number;
to: undefined | string;
value: undefined | bigint;
}
>;

Parameters

The transaction and additional options for conversion

Type

let options: { from?: string; transaction: PreparedTransaction<any> };

Returns

let returnType: Promise<
| {
accessList: undefined | AccessList;
chainId: number;
data: `0x${string}`;
gas: bigint;
gasPrice?: undefined;
maxFeePerGas?: bigint;
maxPriorityFeePerGas?: bigint;
nonce: undefined | number;
to: undefined | string;
value: undefined | bigint;
}
| {
accessList: undefined | AccessList;
chainId: number;
data: `0x${string}`;
gas: bigint;
gasPrice?: bigint;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
nonce: undefined | number;
to: undefined | string;
value: undefined | bigint;
}
>;

A serializable transaction for inspection or submission to an account.