2

Let's take this transaction as an example.

If I use getTransaction method and decode the payload, it will give me information such as:

{
  blockHash: null,
  blockNumber: null,
  from: '0xB54eB0cc6457e9d74e20672D8961faD3CDE4511c',
  gas: 474186,
  gasPrice: '5000000000',
  hash: '0xcf95271d63836f17c0c3a7beda7df2ea7029ce9161dc6808da86f5f9ce740830',
  input: {
    method: 'swapExactETHForTokensSupportingFeeOnTransferTokens',
    names: [ 'amountOutMin', 'path', 'to', 'deadline' ]
    types: [ 'uint256', 'address[]', 'address', 'uint256' ],
    inputs: [
      '152321810000000000',
      [
        'bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
        'd7b729ef857aa773f47d37088a1181bb3fbf0099'
      ],
      'b54eb0cc6457e9d74e20672d8961fad3cde4511c',
      '16211723261200'
    ],
  },
  nonce: 9,
  to: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
  transactionIndex: null,
  value: '5000000000000000',
  v: '0x94',
  r: '0x4bac2f3fd76aecc8a6df23add9dabdb897aed3a2114021f30164867ef6039feb',
  s: '0x6de74caad4ef39d5cd71cd79058675308f725f36184cdc0ce82fc259096c31a9'
}

This describes inputs of the transaction. However, if we look again at the BSCScan transaction, it also includes information about what tokens were transferred:

From PancakeSwap: Router v2
To 0xd423fde466315d45fb0da457df28d5eeb92be580
For 0.005 ($2.97) Wrapped BNB (WBNB)

From 0xd423fde466315d45fb0da457df28d5eeb92be580
To 0xb54eb0cc6457e9d74e20672d8961fad3cde4511c
For 0.154823285118196657 ($2.94) Bogged Finan... (BOG)

How is this information determined?

1 Answer 1

2

The ERC-20 specification describes some events that a token contract must emit when doing certain actions, like transferring tokens. If you look at the logs for the transaction you linked for example, you can see a few Transfer events in there, including the address they were sent from and to, and the number of tokens that were transferred.

web3.eth.getTransactionReceipt includes the logs, which you can decode to check the events emitted by a transaction.

2

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.