Skip to content

Commit 46b9a4d

Browse files
committed
gas estimates for custom writes
1 parent fdf76e6 commit 46b9a4d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Assets/Thirdweb/Core/Scripts/Contract.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ public async Task<TransactionResult> Write(string functionName, TransactionReque
143143

144144
var contract = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContract(this.abi, this.address);
145145
var function = contract.GetFunction(functionName);
146-
var receipt = await function.SendTransactionAndWaitForReceiptAsync(await ThirdwebManager.Instance.SDK.wallet.GetAddress(), null, args);
146+
var gas = await function.EstimateGasAsync(await ThirdwebManager.Instance.SDK.wallet.GetAddress(), null, null, args);
147+
var receipt = await function.SendTransactionAndWaitForReceiptAsync(
148+
from: await ThirdwebManager.Instance.SDK.wallet.GetAddress(),
149+
gas: gas,
150+
value: new Nethereum.Hex.HexTypes.HexBigInteger(0),
151+
receiptRequestCancellationToken: null,
152+
args
153+
);
147154
return receipt.ToTransactionResult();
148155
}
149156
}

0 commit comments

Comments
 (0)