You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have an (admittedly rather unique) situation where one of our dapp's contract functions uses an amount of gas that varies slightly over time, because some of its internal logic is based on the current blockTimestamp. This results in a small chance of transactions randomly failing when relying on gas limits set by wallets simulating the TX ahead of time. For this reason, we manually simulate transactions in our app, and add a small 10% gas buffer on top, which prevents these randomly failing transactions.
We're now working on adding Safe App support to our app, and want to use the Safe Apps SDK's batching functionality to call approve on an ERC-20 and also our own contract's top-up function in one batch for better UX.
This poses a challenge, because we cannot simply simulate these two transactions manually, add the gas cost together, and pass this to the Safe SDK's safeTxGas parameter, because the 2nd transaction depends on the first — so simulating it ahead of time would simply fail.
Just omitting safeTxGas and relying on the Safe's automatic gas estimation also isn't an option, as the transaction could randomly fail for the reason outlined above.
I noticed that when proposing a batch to a Safe, you can click Simulate and it uses Tenderly's batch simulation functionality to simulate the entire batch and calculate a gas cost. I assume that this is how the Gnosis UI generally calculates gas costs for batches.
My feature request: Would it be possible to expose the ability to simulate a batch of transactions with the Safe SDK, and receive a gas estimate? This would allow us to simulate our batch of inter-dependent transactions ahead of time, add our 10% buffer, and then pass the transactions alongside our custom gas limit to the Safe SDK.
The text was updated successfully, but these errors were encountered:
Hey @mikhailxyz, thanks a lot for your response, understood.
That simulate function you linked looks like it could do exactly what we need, but I'm not sure where to start. Do I understand correctly that we could simulate a call against this function with the same batch data we'd later submit to safeAppsSdk.txs.send to get a gas estimate for the entire batch? How would I go about encoding my batch as calldata for simulate? A quick pointer in the right direction would be much appreciated 🙌
We have an (admittedly rather unique) situation where one of our dapp's contract functions uses an amount of gas that varies slightly over time, because some of its internal logic is based on the current blockTimestamp. This results in a small chance of transactions randomly failing when relying on gas limits set by wallets simulating the TX ahead of time. For this reason, we manually simulate transactions in our app, and add a small 10% gas buffer on top, which prevents these randomly failing transactions.
We're now working on adding Safe App support to our app, and want to use the Safe Apps SDK's batching functionality to call
approve
on an ERC-20 and also our own contract's top-up function in one batch for better UX.This poses a challenge, because we cannot simply simulate these two transactions manually, add the gas cost together, and pass this to the Safe SDK's
safeTxGas
parameter, because the 2nd transaction depends on the first — so simulating it ahead of time would simply fail.Just omitting
safeTxGas
and relying on the Safe's automatic gas estimation also isn't an option, as the transaction could randomly fail for the reason outlined above.I noticed that when proposing a batch to a Safe, you can click
Simulate
and it uses Tenderly's batch simulation functionality to simulate the entire batch and calculate a gas cost. I assume that this is how the Gnosis UI generally calculates gas costs for batches.My feature request: Would it be possible to expose the ability to simulate a batch of transactions with the Safe SDK, and receive a gas estimate? This would allow us to simulate our batch of inter-dependent transactions ahead of time, add our 10% buffer, and then pass the transactions alongside our custom gas limit to the Safe SDK.
The text was updated successfully, but these errors were encountered: