2

I am using MetaMask to send a token from one account to another.

In two different transactions, one with Optional Hex data and the other one doesn't has.

When I got geth and use the follow commands:

eth.getTransactionReceipt(<tx hash>)
eth.getTransaction(<tx hash>)
eth.getBlock(<block no>)

They all looks identical in length. I am wondering where does the additional hex data had gone to?

2

You mean sending additional data through the data field?

In the data field of the transaction which is the calldata

See input field at the bottom of the return data, should be that.

var transaction = web3.eth.getTransaction('0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b');
console.log(transaction);
/*
{
  "hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
  "nonce": 2,
  "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
  "blockNumber": 3,
  "transactionIndex": 0,
  "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
  "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
  "value": BigNumber,
  "gas": 314159,
  "gasPrice": BigNumber,
  "input": "0x57cb2fc4"
}
*/

Ethereum transaction

  • Nico, thanks for the answer. However, I am making transaction on a ERC20 token. And I saw that the Input field is filled with (approximately) 68 bytes of data. Is that mean I can't send additional data when making a contract call? – s k Aug 25 '18 at 12:13
  • When you are making a contract call the data contains the encoded function signature and parameters. – Nico Vergauwen Aug 26 '18 at 2:39
  • Can I append additional bytes to the end of the calldata? – s k Aug 26 '18 at 10:38
  • Yes. The first word (32 bytes) will be the function hash, then second word the first param, the third word the second param etc. (all 32 bytes length, padded if necessary). You can append additional bytes as long as you don't interfere with the function 'profile'. msg.sig for example is the first 4 bytes of the first word of the calldata, and will be the function signature in solidity. – Nico Vergauwen Nov 26 '18 at 15:49

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.