3

The Ethereum RPC API documentation accepts a data field when requesting to sendTransaction.

enter image description here

I notice that when I retrieve a historical transaction from the blockchain, I get back an input field and no data field, such as when using the web3 getTransaction function.

Are the data and input fields equivalent, or are there any differences?

1
  • 1
    I believe so, because there is only one "data" field that can be sent in a transaction, along with the other transaction parameters (gas, address, nonce, etc). This data is often called payload data. It is the code that will be executed by the EVM. Feb 23, 2022 at 14:46

1 Answer 1

3

It's the same thing.

When you're going to send a transaction, the data is the combination of: method, parameters which are defined in the ABI, and they're encoded.

data: tokenContract.methods.setPoints(user, point).encodeABI()

When you decode the input data then you'll see something like:

{
  "method": "addLiquidity",
  "types": [
    "address",
    "address",
    "uint256",
    "uint256",
    "uint256",
    "uint256",
    "address",
    "uint256"
  ],
  "inputs": [
    "f45b409a2b978ec02Bb6084e6Acc42867a78Ee9c",
    "326C977E6efc84E512bB9C30f76E30c160eD06FB",
    {
      "type": "BigNumber",
      "hex": "0x043c33c1937564800000"
    },
    {
      "type": "BigNumber",
      "hex": "0x038d7ea4c68000"
    },
    {
      "type": "BigNumber",
      "hex": "0x01"
    },
    {
      "type": "BigNumber",
      "hex": "0x01"
    },
    "f39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
    {
      "type": "BigNumber",
      "hex": "0x61fcafda"
    }
  ],
  "names": [
    "tokenA",
    "tokenB",
    "amountADesired",
    "amountBDesired",
    "amountAMin",
    "amountBMin",
    "to",
    "deadline"
  ]
}

This is created by the encodeABI() function. There's an online lab to check for the input. You can use it to check the input data. Given we can decode it manually, but it faster to use tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.