7

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?

2
  • Do you mean the amount of ether, the third parameter? Commented Jul 13, 2016 at 7:54
  • 1
    No I mean contract.<methodName>.sendTransaction(<params>,{from: <acct-addr>, gas:<some-val> }) . If I skip the gas param altogether, what is the default value for it?
    – Aman C
    Commented Jul 13, 2016 at 8:14

1 Answer 1

5

For Geth, the current default is 90,000 gas.

https://github.com/ethereum/go-ethereum/blob/e61035c5a3630e4f6fd0fb3e5346a4eed8cedc80/internal/ethapi/api.go#L50

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.