Reading my input data on etherscan, I see each value as hex values. Which is fine to read the addresses. But I would like to read the amounts [1] && [3] as numbers.

Contract Method

Function: trade(address tokenGet, uint256 amountGet, address tokenGive, uint256 amountGive, uint256 expires, uint256 nonce, address user, uint8 v, bytes32 r, bytes32 s, uint256 amount)

input data

MethodID: 0x0a19b14a

I made a transaction etherdelta where I bought 25 tokens. So the expected transformed value of the input data [1] should be 25 or 25 * 10^18 (in wei) or at least any multiple of 25*10^x.


How to convert the hex to the expected value?


  1. Using ethereum input decoder shows me the same values as on etherscan.io

  2. converting to Ascii gives garbage (as recommended here: How to decode input data from a transaction?)

  3. web3.utils.hexToNumberString & web3.utils.hexToNumber err

  4. console.log(0x000000000000000000000000000000000000000000000016d8fceafcef3c0000) shows some arbitrary value

  • Do you have the transaction id?
    – Ismael
    Nov 28, 2017 at 18:06

1 Answer 1


From Miguel Mota page, using Etherdelta ABI, and your transaction input I get

  "name": "trade",
  "types": [ .. ],
  "inputs": [
    "16d8fceafcef3c0000",      // <- amountGet
    "8b7363b040ca2bb600000",   // <- amountGive
      "type": "Buffer",
      "data": [..]
      "type": "Buffer",
      "data": [..]
    "38d7ea4c68000"            // <- amount

The commented values are those used to calculate what you receive. This is done in Ethedeleta tradeBalances function

  function tradeBalances(address tokenGet, uint amountGet, 
      address tokenGive, uint amountGive, 
      address user, uint amount) private {
    tokens[tokenGive][msg.sender] = 
       safeMul(amountGive, amount) / amountGet);

You should receive amountGive * amount / amountGet

0x8b7363b040ca2bb600000 * 0x38d7ea4c68000 / 0x16d8fceafcef3c0000 25000000000000000000L = 25*10^18

Which is what you expected.

  • 1
    Ok, the calculation is indeed correct. amount is actually the amount I spend 0.001 eth. amountGive/amountGet is basically the price. I'm still puzzled what amountGive and amountGetis. According to the [overview ](reddit.com/r/EtherDelta/comments/6kdiyl/smart_contract_overview) they should be the amount (in my case 25x10^18 & 4x10^10). > amountGet and amountGive represent the size and price you want to trade
    – Andi Giga
    Nov 28, 2017 at 19:11
  • I'm not an Etherdelta expert, but I'd guess they are the original offer amounts, you only buy less than the total to sell.
    – Ismael
    Nov 28, 2017 at 19:16

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.