I'm working on a Smart Contract and it almost ready. To watch transactions I'm using web2js on my server and its working fine.

But from a transaction detail how I get confirm that given transaction value is in either "Ether" or "ERC Token". I didn't any flag that define about the transaction type. Here is the response of transaction detail:

{ blockHash:'0x9bac7d85939a018cb1d075167c770ec489198ed33b7f80891aacef69bd4f87a0',
  blockNumber: 9240102,
  chainId: '0x1',
  condition: null,
  creates: null,
  from: '0x66527C1CA4d42b5134Eb68DCCd84cD731C683a09',
  gas: 43992,
  gasPrice: '3000000000',
  hash: '0x5e3c2be06257889894a9b486dee5f0009768905a42bb7d88c248a4df9e6cfb7a',
  input: '0xa9059cbb000000000000000000000000d8335af9a17bebba3b418755ab832bc7b5d11269000000000000000000000000000000000000000000000002b5e3af16b1880000',
  nonce: 63,
  publicKey: '0x093c647b00303b10f8fadb83bf25e76516d385c3b82724e454bc2ce0c044fb5b9e4fa32e5e70a837244f6312621f554b4424d801eecf0457f59a345dcb679d2b',
  r: '0xe0e5e40894b99f43d32a10ea0594eca8ff5a81dd7bc63b01e9f5da422ebda82f',
  raw: '0xf8a83f84b2d05e0082abd894410af23334e26aa13c1f3e630bae006bdd31326480b844a9059cbb000000000000000000000000d8335af9a17bebba3b418755ab832bc7b5d11269000000000000000000000000000000000000000000000002b5e3af16b188000025a0e0e5e40894b99f43d32a10ea0594eca8ff5a81dd7bc63b01e9f5da422ebda82fa00cd88104353205455666a4cc30e22892926dded16e73766d03fab94619e80c70',
  s: '0xcd88104353205455666a4cc30e22892926dded16e73766d03fab94619e80c70',
  standardV: '0x0',
  to: '0x410af23334e26aa13C1f3e630Bae006bdD313264',
  transactionIndex: 61,
  v: '0x25',
  value: '0'

In this above response how I identify that what was sent from sender (ETH or Token)


1 Answer 1


Token transfers are not actually transfers of value at all. Only Ether transfers explicitly transfer (and contain) value. So a transaction transfers Ether if and only if its value field is non-zero.

Detecting a token transfer is much more tricky. A token transfer is simply calling a function in a token contract. So first you need to know whether the receiving contract is a token contract (this is quite difficult to find out: Detect token transaction to a contract How is a contract determined to be ERC20 compliant? ). After that you can monitor for Transfer events but unfortunately this does not guarantee anything either - it's just basically the best we can do.

A token transfer may also contain value but not typically.

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.