2

Based on https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call

The data is optional, but it also says it contains hash of the method signature.

In what scenario you can send a eth_call without data field?

1

Documentation can be is a bit misleading here, I think because it aims to simplicity. The following statement from the current RPC official documentation:

data: DATA - (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI in the Solidity documentation

It should contains more details, maybe something like this:

data: DATA - (optional) It contains arbitrary data. When calling a smart contract, DATA will be made available to it. Because Solidity is often used to develop and to compile smart contracts, DATA usually contains hash of the method signature and encoded parameters for the smart contract. See Ethereum Contract ABI in the Solidity documentation for more details.

Under the hood, Solidity compiler transforms smart contract's functions into separate pieces of EVM instructions, and it also automatically inserts a selector - or switch statement - at the beginning of every compiled contract. The selector's duty is to redirect the execution flow to a specific piece of code based on parameters sent by caller through the data field.

| improve this answer | |
  • Thanks. I found that too after took a close look at how a contract call executed on EVM. – Kabie Jun 10 at 11:43
1

When data is empty (and there is no receive ether function) the fallback function will be called.

See: https://solidity.readthedocs.io/en/v0.6.8/contracts.html#fallback-function

Prior to Solidity 0.4.0 this was used to send ETH to a contract.

| improve this answer | |
  • Yeah, but what exactly is the point in doing an RPC on the fallback function? It doesn't return anything, so calling it NOT in a transaction seems pointless. – goodvibration Jun 3 at 8:07

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.