2

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

4

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.

| improve this answer | |
  • Thanks, kindly show me some example call data stuff which I can use in this particular case. Also I can't understand which part of my code makes it imperative to use call data (my code has only payable constructor and fallback function). – zak100 Feb 11 at 20:46
  • 1
    @zak100 frecuently I also miss the most important explanation: the example. So.. here a simple example of transferring 10ether from 0x..34a2 to 0x..a2c4: web3.eth.sendTransaction({from: "0x...34a2", to: "0x...a2c4", value: web3.utils.toWei(10)}) – José Crespo Barrios Nov 9 at 12:07
  • 1
    Web3 is giving you friendly ways to express your intention and it's doing work for you. Your JavaScript has to be encoded into bytes formatted in a way Etheruem understands. The EVM doesn't care how you make raw data, as long as you do. Have a look over here: ethereum.stackexchange.com/questions/87299/… – Rob Hitchens Nov 9 at 19:29

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.