-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
estimate the gas cost of a SC call #439
Comments
nb: maybe 266754 is the value i am searching and to be used in "coin" parameter of callSmartContract, but it would be nice to return it withour throwing :) |
Something that will be greatly improve the developer experience, is to make the "fee" and "coins" parameters optionnal in callSmartContract. and it not provided web3 will internally call that "estimategas" function and set the appropriate values. |
You should always place the max in maxgas of a readCallSmartContract so that it will return you the gas used that you can use for your estimation. The maxGas could be useful in readCallSmartContract in case you want to try if an amount of gas is enough for an execution. Maybe the exact max doesn't work try a bit lower. |
about mas gas estimation, we see in practice that sometimes the gas estimated by massa-web3 just before submitting the operation is not enough. The read only return a amount of gas and it's not enough for the actual call executed just after. To prevent this, either fix a bug in the node or add +20 % to the estimation. |
@AurelienFT How the read could return less gas than needed to make the call ? |
In order to set appropriate gas fee and "coins" when calling a SC function (write call with callSmartContract) I need a way to estimate it given the actual network conditions.
Prior to submit my operation, i was said that i can use "readSmartContract" to get this estimation.
So I tried and it seems there is a bug with maxGas:
when i put a random amount a got something like
Not enough gas, limit reached at: increaseAllowance | Init cost is 266754
I precise that i tried with a value > 266754
if i put a big value like 1000000000000
The gas submitted 1000000000000 exceeds the max. allowed block gas of 4294967295
if i put the max allowed value 4294967295, the function throws
So i think there is a bug to fix. and also, what is the meaning of "maxGas" here ??? readonly is supposed to be free, right ?
The text was updated successfully, but these errors were encountered: