Basically you don't need to pay fee for contract call, but if a contract method does lots of work, you need to add gas in contract call to prevent DoS attack like this:

contract.method.call({gas: 1000000000})

Who gets this fee?

  • I think this is mostly answered over here: ethereum.stackexchange.com/questions/11/…. I might add that Ethereum returns unspent gas. It that sense, it's an upper bound for execution. Other little detail is that if the transaction throws for some reason instead of executing successfully, then the gas (all of it) is destroyed forever. – Rob Hitchens Dec 23 '16 at 12:25
  • It doesn't looks like the answer. Who gets the fee? – Satoshi Nakanishi Dec 23 '16 at 12:35

"Call" is an overloaded term because it is one form of invoking a contract (see What is the difference between a transaction and a call?) and it depends where the invocation is performed, in relation to the Ethereum Virtual Machine (EVM).

Outside the EVM (eg web3.js)

The question's contract.method.call({gas: 1000000000}) deals with web3.js, which is outside of Solidity and the EVM.

The web3.js API is web3.eth.call and is what's used for Solidity constant functions.

No one gets the fee because the "dry run" invocation is local to the node that web3.js is connected with: the network and miners do not know anything about this invocation.

However, even though the invocation is local, gas is still "used" and it is still possible to run Out of Gas or (self) "DoS" when invoking a Solidity constant function. For example, as explained in Can Solidity constant functions be arbitrarily complex?, Geth "only" provides local invocations with 50 million gas:

if gas.Cmp(common.Big0) == 0 {
    gas = big.NewInt(50000000)

To avoid a "self DoS", try more gas like contract.method.call({gas: 999000000})

A more accurate reason why no one gets the fee is that gas is metering, and metering is different from fees, excerpt:

In Bitcoin, metering is done with bytes: the number of bytes in the transaction. In Ethereum, computation also needs to be metered because a small amount of code could still be a program that runs forever. Metering computation is one of the reasons for gas. But having gas doesn’t mean requiring fees.

For example, in a private chain each account could have X gas per day, or each account could have Y gas per transaction, or some other scheme. On the flip side, having fees doesn’t mean requiring gas: fees can be based on different metering, such as bytes. Security in a public blockchain requires both gas and fees, while the alternatives are more applicable to private chains (for example, a scheme where each account has X gas per day can be Sybil-attacked in a public chain where anyone can create an account).

A contract invocation with a web3.eth.call is still metered, even though there's no resulting fee, and that's why gas is still involved.

Inside the EVM (eg Solidity)

In Solidity, call is a different beast altogether and is a low-level feature for a contract to send another contract a message, as explained in What does Solidity's "call" function mean?

One thing to note is when .gas is used, for example:


it means that the subcall invocation to methodName will be limited to 1000 gas: it does not mean provide 1000 more gas to methodName.

If the Solidity is being executed in the context of a "dry run" local invocation, then the transaction fee goes to nobody. If the Solidity is being executed in a transaction, the fee always goes to the miner of the block, even if there is an Out of Gas or execution error of any kind.

  • I still don't understand many things. I was asking about outside the EVM call. It is said that gas is still "used", but no one gets the fee. If the gas is used, where does the fee go? Does it disappear? or You just need to specify the fee, but the fee is not sent or doesn't go to anyone? – Satoshi Nakanishi Dec 24 '16 at 17:40
  • When the execution doesn't interact with the blockchain, the transaction originator's eth balance will be unchanged at the end. – Rob Hitchens Dec 25 '16 at 17:16
  • If the sender's balance is unchanged, what's the point to specified the gas in the method call? Why is this called "gas is used"? If the balance is not changed, it sounds like gas is not used. – Satoshi Nakanishi Dec 26 '16 at 2:48
  • Thanks for the questions, I've updated this answer to explain metering and also added another one that I hope helps: ethereum.stackexchange.com/a/10940/42 – eth Dec 26 '16 at 9:45
  • I probably understand what you meant now. What you meant by "Gas is used" is that gas parameter is need to be specified in call method if you are going to use more than 50 million gas. Am I right? – Satoshi Nakanishi Dec 26 '16 at 15:44

In the case that the transaction executes successfully, the actual fee goes to the miner that solves the block. To avoid redundancy, I'll just point to some details here: How do Ethereum's transaction fees compare to Bitcoin?. The take-away here is that the fee will not be 1000000000 in most cases, but it won't exceed it.

In the case of execution error, the gas is destroyed forever, so no one receives it.

It also bears mentioning that in the case of "call" (versus sendTransaction), the execution will be local and it won't cost gas, so in the end, the caller will still have the gas that was pledged. Using "call" is common for read-only operations that won't change state because it's faster and it's free.

  • 1
    Using "call" isn't always free. As I wrote in the first post, you need to add the gas when the method does the lots of work even if you use the "call". – Satoshi Nakanishi Dec 23 '16 at 13:10
  • I see what you're getting at now. I'm open-minded and curious. Where can I find an explanation of call isn't always free? – Rob Hitchens Dec 23 '16 at 13:22
  • I think there is no explanation, so please ask geth comitters. – Satoshi Nakanishi Dec 23 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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