What is the default value for gas in sendTransaction api? Suppose I don't specify gas parameter in the sendTransaction api, what will be used?
Also, will this vary if it is a contract transaction instead of normal ether send transaction?
What is the default value for gas in sendTransaction api? Suppose I don't specify gas parameter in the sendTransaction api, what will be used?
Also, will this vary if it is a contract transaction instead of normal ether send transaction?
For Geth, the current default is 90,000 gas.
defaultGas = 90000
But unless you're doing a plain Ether transfer (no data
and costs 21,000 gas), it is best to specify a value to reduce chances of running Out of Gas.
The default gas doesn't vary according to the transaction. The difference between invoking a transaction and a normal ether send is that the latter has empty data
field, and this code makes no check on args.Data
:
https://github.com/ethereum/go-ethereum/blob/e61035c5a3630e4f6fd0fb3e5346a4eed8cedc80/internal/ethapi/api.go#L1151
The code also doesn't change the gas for a transaction that creates a contract: https://github.com/ethereum/go-ethereum/blob/e61035c5a3630e4f6fd0fb3e5346a4eed8cedc80/internal/ethapi/api.go#L1149