Docs

Unity 4.17.0 - Transaction Builder Improvements

Firekeeper

Long story short, you can now do things like this

var contract = ThirdwebManager.Instance.SDK.GetContract("0xEBB8a39D865465F289fa349A67B3391d8f910da9");
var tx = await contract.Prepare("approve", "0x29433d52FA37cDa73D31c759F466be1Cb1764812", 0);
Debug.Log($"Transaction input before preparing: {tx}");
// This step is optional if you don't care about visualizing the input, tx.Send will do it for you
_ = await tx.Popuate();
Debug.Log($"Transaction input after preparing: {tx}");
// You may update the input if you want
var increasedGasLimit = tx.Input.Gas.Value * 10 / 9;
_ = tx.SetGasLimit(increasedGasLimit.ToString());
var hash = await tx.Send();
Debug.Log($"Transaction hash: {hash}");
// or you can wait for the transaction to be mined if you don't care about the hash
// var receipt = await tx.SendAndWaitForTransactionResult();
// Debug.Log($"Transaction receipt: {receipt}");

What's Changed

  • [Cross-Platform] General improvements and cleanup of the low-level Transaction builder class, typically created from Contract.Prepare.
    • Added Transaction.Populate - a way for you to prepare a transaction by populating all its fields without sending it.
    • Added Transaction.GetGasFees to get EIP-1559 max fee per gas and max priority fee per gas.
    • Contract.Prepare will now return fully populated Transaction including Data cross platform, instantly.
    • Fixed edge case where if a chain did not support EIP-1559, and no max fee/max priority fee were explicitly set but a gas price was explicitly set, the gas price would be recalculated and overriden.
  • [Cross-Platform] Added Wallet.GetNonce - a simple way to get the connected wallet's nonce, defaults to pending blockTag but can be overriden.
  • [Cross-Platform] Removed the Contract.Prepare variant that takes in a from address override to avoid confusion and simplify syntax.
  • [Cross-Platform] Added support for new chains.
  • [WebGL] Updated bridge.

Release: https://github.com/thirdweb-dev/unity-sdk/releases/tag/v4.17.0