0
web3.eth.getTransaction('0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b§234')
.then(console.log);

> {
    "hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
    "nonce": 2,
    "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
    "blockNumber": 3,
    "transactionIndex": 0,
    "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
    "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "value": '123450000000000000',
    "gas": 314159,
    "gasPrice": '2000000000000',
    "input": "0x57cb2fc4"
}

Seeing the transactions details from web3() like above, how would I know that whether it is a ethereum transaction or a token transaction? Can you please give me some insights?

1 Answer 1

2

Token transactions have the token's contract address as their "to" field, like this:

"to": "0x983f6d60db79ea8ca4eb9968c6aff8cfa04b3c63"

Contract address:
https://etherscan.io/token/0x983f6d60db79ea8ca4eb9968c6aff8cfa04b3c63 Transaction involving the token: https://etherscan.io/tx/0x391c0b6196295595e9ff1f660eb2dc98570a39d35a99d7d48c266ab6caf2d560

See that the transaction page on Etherscan shows you the contract address as "to". The number of tokens and their target address are figured out from "input" field, which incorporates contract method being called and its arguments, if any. For token transfers it should be longer than what your example has, because at the very least it should contain the target address for tokens.

3
  • Thank you for your message! etherscan.io/tx/… is this transaction, where exactly the recevers address is stored? in the input? Is it encoded?
    – Jab2Tech
    Commented Sep 18, 2018 at 17:04
  • Because I searched the trasnction row data, but was not able to find the receiver address "0x9a477886d78884c187d438bce63e56ab9747d3b6" in it. Is it stored encoded in input field?
    – Jab2Tech
    Commented Sep 18, 2018 at 17:07
  • 1
    Check the "view input as" button under "input data", pick "Original" and you'll see a sequence containing the tokens receiver address. What's separated by zeros is: contract method id and 2 of its arguments - receiver address (without 0x prefix) and the number of tokens transferred.
    – Utgarda
    Commented Sep 18, 2018 at 17:09

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.