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?
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?
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.
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.