[Ethereum] Remix IDE: What is the purpose of Calldata and Transact Tab

calldataremix

I am trying to execute the following code on Remix IDE.

pragma solidity ^0.5.4;
contract GuessTheNumberChallenge {
    constructor() public payable {
        require(msg.value == 1 ether);
    }
    function () external payable {}

}

It shows me the Calldata box with Transact tab as shown in the Diagram. If I type 10 in the call data box and click transact, I got the following transaction receipt:

[vm]from:0xca3…a733cto:GuessTheNumberChallenge.(fallback)
0x692…77b3avalue:0 weidata:0x10logs:0hash:0xe19…310b7 status 0x1
Transaction mined and execution succeed transaction hash
0xe199a02ea06f556f01175fb3e5726c60a30aee092b86f92ca72e6429fdf310b7
from 0xca35b7d915458ef540ade6068dfe2f44e8fa733c to
GuessTheNumberChallenge.(fallback)
0x692a70d2e424a56d2c6c27aa97d1a86395877b3a gas 3000000 gas
transaction cost 21086 gas execution cost 18 gas hash
0xe199a02ea06f556f01175fb3e5726c60a30aee092b86f92ca72e6429fdf310b7
input 0x10 decoded input – decoded output – logs []

I can’t understand following:

[vm]from:0xca3…a733cto:GuessTheNumberChallenge.(fallback)
0x692…77b3avalue:0 weidata:0x10logs:0hash:0xe19…310b7

If I type "10 ETHER", I am getting the message "hexadecimal value required"
What is meant by
0 weidata:0x10logs:0
Is the Calldata with Transact used to transfer Ether? or its related to address?

Somebody please guide me.

Zulfi.

Calldata, Transact tab and ETHER

Best Answer

Ethereum transactions follow a certain low-level structure:

  • from: address (signed by this)
  • to: address
  • value: uint (ether)
  • data: message data bytes

The first four bytes of data are a function selector, where the selector is derived from a hash of the function name (source code) and arguments, truncated to four bytes. After that comes the arguments. That's all unpacked when it arrives so the EVM knows which function to run and the input arguments.

Remix is uses the source code to work out the friendly function interface, above, with each function named and the arguments accepted and conveniently packed into calldata for you.

It is also possible to create the message data yourself (by some other method), and use calldata to send your raw transaction data.

Hope it helps.

Related Topic