ThirdwebTransaction Static Methods

The ThirdwebTransaction class includes several static methods that provide functionality to estimate costs, simulate, send and poll transactions and user operations.

These methods are crucial for advanced transaction management and execution in blockchain applications.

ThirdwebTransaction.EstimateGasCosts

Estimate the gas costs of a transaction.

TotalCosts gasCosts = await ThirdwebTransaction.EstimateGasCosts(transaction);

ThirdwebTransaction.EstimateTotalCosts

Calculate the total costs of a transaction, combining the gas costs and transaction value.

TotalCosts totalCosts = await ThirdwebTransaction.EstimateTotalCosts(transaction);

ThirdwebTransaction.EstimateGasLimit

Estimate the gas limit of a transaction or user operation.

BigInteger estimatedGasLimit = await ThirdwebTransaction.EstimateGasLimit(transaction);

ThirdwebTransaction.EstimateGasPrice (Legacy)

Estimate the gas price for a transaction, optionally adjusting the estimate by a bump ratio.

BigInteger estimatedGasPrice = await ThirdwebTransaction.EstimateGasPrice(transaction, withBump);

ThirdwebTransaction.EstimateGasFees (EIP-1559)

Estimate the gas fees for a transaction, optionally adjusting the estimate by a bump ratio.

(BigInteger maxFeePerGas, BigInteger maxPriorityFeePerGas) = await ThirdwebTransaction.EstimateGasFees(transaction, withBump);

ThirdwebTransaction.Simulate

Simulate the execution of a transaction and return raw data.

string data = await ThirdwebTransaction.Simulate(transaction);

ThirdwebTransaction.Sign

Sign a raw transaction and returns the signed transaction data or the signed user operation json.

string signedTx = await ThirdwebTransaction.Sign(transaction);

ThirdwebTransaction.Prepare

Prepares the transaction for sending by setting default values for any unset fields, such as gas limits and gas prices.

ThirdwebTransaction preparedTransaction = await ThirdwebTransaction.Prepare(transaction);

ThirdwebTransaction.Send

Send a transaction to the blockchain without waiting for confirmation.

string transactionHash = await ThirdwebTransaction.Send(transaction);

ThirdwebTransaction.SendAndWaitForTransactionReceipt

Send a transaction and wait for its receipt.

TransactionReceipt receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(transaction);

ThirdwebTransaction.WaitForTransactionReceipt

Wait for a transaction receipt to be available. Throws if reverted explicitly or silently and attempts to decode the revert reason.

TransactionReceipt receipt = await ThirdwebTransaction.WaitForTransactionReceipt(client, chainId, txHash);