Show log events and decode them in API response for getWalletTokenIdTransfers

/nft/{token_address}/{token_id}/transfers

I’m using getWalletTokenIdTransfers() to get the transaction history of each NFT of single NFT pages in an app but the problem on Polygon is that the value shows MATIC fees and not wrapped ETH that these NFTs are bought with on OpenSea.

It also doesn’t show any info about the type of event for each transaction.

What I’m doing now to solve this is I run getWalletTokenIdTransfers() and check if the value is more than 0.

If it is then that means it was purchased and then I have to use Covalent to get the info for the transaction using the tx_hash.

Covalent shows a lot more data for transactions including log events, gas fees and events are decoded so you can see what actual contract events are called like Fill() event then I can see the "takerAssetFilledAmount" and wETH value sent.

It would be more convenient to just use Moralis API for everything if some of this extra data was included in responses.

Try these to see example of data returned:

Covalent example on Polygon - Get NFT transactions for contract:

contract: 0xa5f1ea7df861952863df2e8d1312f7305dabf215
token_id: 158139

Covalent example on Polygon - Get a transaction:

tx_hash: 0x217b89c396d93620738b6060a52e75a38288005c248e64cdbc920ee54b400e74

You could also use getTransaction and then decipher the token amounts from the logs in the same way.

Any tips on how to decode those hashes in the txn results?

Can you give an exact example of what you want to decode?

For that transaction hash, you look at the logs that involve the wETH address (0x7ceb23fd6bc0add59e62ac25578270cff1b9f619).

{
      "log_index": "114",
      "transaction_hash": "0x217b89c396d93620738b6060a52e75a38288005c248e64cdbc920ee54b400e74",
      "transaction_index": "32",
      "address": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
      "data": "0x0000000000000000000000000000000000000000000000000021c0331d5dc000",
      "topic0": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "topic1": "0x0000000000000000000000009396c0fed2af8257f59437f461de1c8ff7b06630",
      "topic2": "0x0000000000000000000000005dda0c89399fde4af28e4fca3fc7724f31a994bd",
      "topic3": null,
      "block_timestamp": "2022-08-23T02:56:20.000Z",
      "block_number": "32214019",
      "block_hash": "0xbb537a7a3c3c11f39566dce744c913fdaa747408a9d5a037b6974851659d3879",
      "transfer_index": [
        32214019,
        32,
        114
      ],
      "transaction_value": "10830000000000000"
}

Hex of 21c0331d5dc000 converted to decimal becomes 9500000000000000, divided by token decimals or 18 becomes 0.0095 wETH for that transfer.

You can get the function name (Transfer), from/to address in a similar way.

So it’s a little bit more work if you want to use Moralis API.

If the transactions are mainly with OpenSea, it may be easier to use the OpenSea API instead.

Ahh ok I get it.

Thanks for the tips!