Transaction Builder

By default, all transactions initiated using the SDK perform every step of the process for a transaction; From preparing and building the transaction all the way to waiting until it has been mined, and the data is available to be read from the blockchain.

To gain more granular control over the transaction process, all Contract objects come with a Prepare function that returns a Transaction object, which can be used to build, fine-tune, and execute the transaction.


string connectedAddress = await ThirdwebManager.Instance.SDK.wallet.GetAddress();
Transaction transaction = await contract.Prepare(
functionName: "claim",
from: connectedAddress, // optional, defaults to connected address
args: new object[] { connectedAddress, 0, 1 }
// transaction.SetValue("0.00000000001");
// transaction.SetGasLimit("100000");
var data = await transaction.Simulate();
Debugger.Instance.Log("[Custom Call] Simulate Successful", $"Data: {data}");
catch (System.Exception e)
Debugger.Instance.Log("[Custom Call] Simulate Error", e.Message);
await transaction.EstimateAndSetGasLimitAsync();
var gasPrice = await transaction.GetGasPrice();
Debug.Log($"Gas Price: {gasPrice}");
var gasCosts = await transaction.EstimateGasCosts();
Debug.Log($"Gas Cost: {gasCosts.wei} WEI");
Debugger.Instance.Log("[Custom Call] Transaction Preview", transaction.ToString());
string transactionResult = await transaction.Send(gasless: false);
Debugger.Instance.Log("[Custom Call] Send Successful", "Tx Hash: " + transactionResult);
catch (System.Exception e)
Debugger.Instance.Log("[Custom Call] Send Error", e.ToString());


Estimate the gas cost for a transaction.

var gasCost = await tx.EstimateGasCosts();


Estimate the gas limit for a transaction.

var gasLimit = await tx.EstimateGasLimit();


Send the transaction without waiting for it to be mined. This is useful for when you want the transaction to be executed, but don’t need the data returned.

string txHash = await tx.Send();


Send the transaction and wait for it to be mined. This is useful for when you want the transaction to be executed, and need the data returned.

TransactionResult result = await tx.SendAndWaitForTransactionResult();

Static Methods

Useful static methods for working with transactions.

string txHash = "your_tx_hash";
TransactionResult result = await Transaction.WaitForTransactionResult(txHash);