Ethereum Series - Understanding data payloads in Transactions

Manan Patel
The Startup
Published in
3 min readAug 9, 2019

--

source — themerkle.com

Any transaction with data payload is meant to be addressed to a smart contract. These types of transactions usually invokes a function on smart contract. Such transactions (with data and no value) are called Invocations. And transactions containing only data are called Payments. But, for now let’s stick to Invocations.

Disclaimer — You can still send data payload to a user account (aka Externally Owned Account). Yes, it is possible. It is a valid ethereum transaction, but that data doesn’t change any state on blockchain. It is ignored by the Ethereum protocol. One use case for such approach would be for wallets to communicate with each other by sending metadata(as data payload) with the Payment (transaction with value and no data).

According to the solidity documentation, the data payload sent to a smart contract is a hex-serialized encoding of -

  • Function Selector- The first 4 bytes if Keccak-256 hash of the function’s prototype along with the argument types (Since, solidity allows function overloading). This allows the contract to unambiguously identify which function to invoke.
  • Function Arguments- The function’s arguments, encoded according to the rules for the various elementary types defined in ABI specification.

--

--

Manan Patel
The Startup

Building and experimenting with innovative tech