Get Wrapped ETH amount paid on Polygon network NFT transaction

I just noticed an issue getting transaction history for an NFT on polygon. The sales on OpenSea on in Wrapped ETH (wETH).

Iā€™m using getWalletTokenIdTransfers() to get the transaction history for single token IDs. The value it returns is a MATIC fee and not the amount of ETH paid.

const fetchNFTTransfers = async () => {
        try {
          const options = {
            chain: 'polygon',
            address: '0x67F4732266C7300cca593C814d46bee72e40659F',
            token_id: '555',
          };

          const resp = await Moralis.Web3API.token.getWalletTokenIdTransfers(
            options
          );

          const data = await resp.result;

        } catch (err) {
          console.error(err);
        }
      };

This is one of the OpenSea sales transactions returned which has a value:

amount: "1"
block_hash: "0x507e8ffacbde64dbed5bb78baf1db049238399facb4268c14cdbe50b6a4bf618"
block_number: "30689343"
block_timestamp: "2022-07-13T19:01:30.000Z"
contract_type: "ERC721"
from_address: "0xaf6a968a7563bb8fcb999290792c8b357f7b5839"
log_index: 64
operator: null
to_address: "0xb8a376f55c9ec030b070bcae233aae471d9aa9e0"
token_address: "0x67f4732266c7300cca593c814d46bee72e40659f"
token_id: "555"
transaction_hash: "0x64c5eb5dc4c67f5047248c1f22cd5e67ce3ffbe769f63c5cf8406282d4cb1e92"
transaction_index: 12
transaction_type: "Single"
value: "27000000000000000"
verified: 1

If you check PolygonScan you see the value is 0.027 MATIC but under ā€œTokens Transferredā€ the sale price of 5.5 ETH is there. Thats the number I need but it doesnā€™t look like any of the Web3Api returns this data.

https://polygonscan.com/tx/0x64c5eb5dc4c67f5047248c1f22cd5e67ce3ffbe769f63c5cf8406282d4cb1e92

Does anyone know if there is a way to get the ETH tokens transferred from this one transaction?

I thought maybe I could run a new search on that txn hash for the WETH contract address but doesnā€™t look like any of the Web3APIā€™s are setup to do this.

Have you looked at using the OpenSea API?

Another option is to use getTransaction and manually go through the Transfer event logs to get the wETH amounts.

1 Like

Oh nice, I didnā€™t see the getTransaction function.

I was thinking of doing that using Covalent and loop through the logs.

Thank you