.NET SDK

ThirdwebContract.Prepare

ThirdwebContract.Prepare bridges contract interactions and the transaction tooling within the Thirdweb .NET SDK. Use it when you want to start from a contract method, but need fine-grained control over the resulting ThirdwebTransaction before dispatching it.

Why prepare first?

  • Simulation & inspection – Prepare the transaction and run ThirdwebTransaction.Simulate before sending.
  • Customization – Chain the ThirdwebTransaction instance methods to adjust calldata, value, gas, or paymaster options.
  • Wallet-agnostic – Works with any IThirdwebWallet, letting you bridge user wallets, smart wallets, or server wallets into the same flow.

Usage

ThirdwebTransaction transaction = await contract.Prepare(
wallet,
contract,
"methodName",
weiValue,
parameters
);

Once prepared, you can tweak or send the transaction:

// Optional: override calldata, value, or other fields
transaction = transaction
.SetValue(BigInteger.Zero)
.SetGasLimit(250000);
// Optional: simulate or estimate costs
await ThirdwebTransaction.Simulate(transaction);
var totalCosts = await ThirdwebTransaction.EstimateTotalCosts(transaction);
// Finally: send the transaction and wait for the receipt
TransactionReceipt receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(transaction);

Parameters

Return value