I'm new to ethereum and I would like to confirm a few things about Transaction.

I've transferred tokens and I would like to extract method, address transferred to and amount from Transaction(org.web3j.protocol.core.methods.response). I've extracted Transaction with web3j

  "hash": "0xfa9007eae34dfac8813a2f49d2514ceec881ebc5c33a8e7ad3dd229861e32e52",
  "nonce": 1449,
  "blockHash": "0xb2376edfeea3800afc7678ea00e761e3766ae0d9cefc17adbf7148bce3f4e459",
  "blockNumber": 1734050,
  "transactionIndex": 0,
  "from": "0x0124ceea90258dc124b698f3c88fee8eec0c3d10",
  "to": "0xecbe04bbe35b70c91ba62ec229de49eea97e4a0d",
  "value": 0,
  "gasPrice": 100000000000,
  "gas": 6000000,
  "input": "0x40c10f19000000000000000000000000a4d0fb50a216d005d0510743686bfca140856f4500000000000000000000000000000000000000000000003635c9adc5dea00000",
  "creates": null,
  "publicKey": null,
  "raw": null,
  "r": "0xe03ac6d55cd81f8ba0d0575a9455db86169e0b6d6dbbc255058dd67441913ff1",
  "s": "0x24a2f26c05f80f1b0ba97eddc2f4c82424155db5f5659db834353cc8d0170581",
  "v": 44,
  "gasRaw": "0x5b8d80",
  "nonceRaw": "0x5a9",
  "valueRaw": "0x0",
  "gasPriceRaw": "0x174876e800",
  "blockNumberRaw": "0x1a75a2",
  "transactionIndexRaw": "0x0"

It looks like all the necessary data is in field input(methodId, to, amount). Check input data in transaction

So I would like to confirm following things:

1) Is Checking methodId 0x40c10f19 enough to confirm that method mint was called?

2) Is there a good way to parse input field (like library e.t.c), it doesn't really looks great to parse it manually.

3) Is there some official description that describes what input field generally contains? (I found nothing here)

4) Could the format of input field change for the same contract's successful transaction? By this I mean if I parse input field myself could there be any problems with in like order of fields have changed or a new parameter would be added to field thus leading my parameter to work in improper way?


1 Answer 1


If you just want to check if the mint() function was called this is the part that you are interested in

"input": "0x40c10f19000000000000000000000000a4d0fb50a216d005d0510743686bfca140856f4500000000000000000000000000000000000000000000003635c9adc5dea00000",

The first 4 bytes of the payload are 0x40c10f19 and these uniquely identify the function signature mint(address,uint256)

You can check this yourself by feeding the ABI or the function definition to this tool (I built this tool)

$ node main.js func2sig "mint(address,uint256)"
Computing function signature mint(address,uint256)
mint(address,uint256) -> 0x40c10f19

Or hashing the function signature with a keccak256 hashing tool will create this hash 40c10f19c047ae7dfa66d6312b683d2ea3dfbcb4159e96b967c5f4b0a86f2842. The first 4 bytes define and match the function signature you see in the input.

The rest of the input is split into 32 bytes arguments.

address _to    = 000000000000000000000000a4d0fb50a216d005d0510743686bfca140856f45
uint256 _value = 00000000000000000000000000000000000000000000003635c9adc5dea00000

This is specific to Solidity, other languages can store the arguments differently.

To answer your questions:

1) Checking the method id is enough to confirm the method mint() was called

2) You can use my tool, feed the ABI to it and compute all function and event signatures.

3) Input field contains the function signature and arguments padded as 32 bytes.

0x[function signature][argument 0][argument 1]...
  |  ^ 4 bytes        |^ 32 bytes |^ 32 bytes

4) If the function changes (order of arguments, new arguments, function name) the function signature will change. UNLESS arguments that changed order have the same type. However this should not happen because the functions should adhere to a ERC standard.


  • 1
    Thanks, just found another lib to get MethodId org.web3j.abi.FunctionEncoder.buildMethodId("transfer(address,uint256)");
    – Evgen
    Feb 8, 2018 at 11:51

Your Answer

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

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