ThirdwebTransaction Instance Methods

The ThirdwebTransaction class provides a set of instance methods to set various properties of your transaction's input data and gas settings.

Do note that in most cases those are autopolulated by the SDK and you don't need to set them manually.

ThirdwebTransaction.SetTo

Set the target address or contract of the transaction.

ThirdwebTransaction transaction = transaction.SetTo("0xToAddress");

ThirdwebTransaction.SetData

Set the raw encoded data payload (potentially overriding previous data if the transaction was created using ThirdwebContract.Prepare).

ThirdwebTransaction transaction = transaction.SetData("0x");

ThirdwebTransaction.SetValue

Set the value of the payable transaction in Wei.

ThirdwebTransaction transaction = transaction.SetValue(1000000000000000000);

ThirdwebTransaction.SetGasLimit

Set the gas limit of the transaction.

ThirdwebTransaction transaction = transaction.SetGasLimit(21000);

ThirdwebTransaction.SetGasPrice

Set the gas price of a legacy transaction.

ThirdwebTransaction transaction = transaction.SetGasPrice(1000000000);

ThirdwebTransaction.SetNonce

Set the nonce of the transaction.

ThirdwebTransaction transaction = transaction.SetNonce(1);

ThirdwebTransaction.SetMaxFeePerGas

Set the maximum fee per gas of an EIP-1559 transaction.

ThirdwebTransaction transaction = transaction.SetMaxFeePerGas(1000000000);

ThirdwebTransaction.SetMaxPriorityFeePerGas

Set the maximum priority fee per gas of an EIP-1559 transaction.

ThirdwebTransaction transaction = transaction.SetMaxPriorityFeePerGas(1000000000);

ThirdwebTransaction.SetChainId

Set the chain ID of the transaction.

ThirdwebTransaction transaction = transaction.SetChainId(1);

ThirdwebTransaction.SetZkSyncOptions

Set the ZkSync options of the transaction.

This allows you to use native ZkSync Account Abstraction with any paymaster.

ZkSyncOptions zkSyncOptions = new ZkSyncOptions("0xPaymaster", "0xPaymasterInput");
ThirdwebTransaction transaction = transaction.SetZkSyncOptions(zkSyncOptions);