JSON-RPC – How to Retrieve ENS Domain Transfers Using Alchemy Transfers API with alchemy_getAssetTransfers

alchemyensjson-rpctransfers-api

I'm using the Transfers API (Tx History) — Internal Eth Transfers, but i cant get ENS txns in its response.

Here is the json rpc request I'm making:


{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "alchemy_getAssetTransfers",
  "params": [
    {
      "fromAddress": "0xDce63CBee5E3f5d30729b777a11385B58b711a3c",
      "excludeZeroValue": true,
      "withMetadata": true,
      "category": [
        "internal",
        "erc20",
        "erc721",
        "erc1155",
        "specialnft"
      ]
    }
  ]
}

I expect the ENS domain transfer that shows up in this transaction hash (0xc97431eec5791405982b3d1873ed38062e5ea2542997aad9468efb28075bc88f) to appear in the api call response, but it isn't there.

How can I debug this?

Best Answer

Alchemist here 💙

There are two things you can do to repro/debug:

1. Use the Alchemy Composer:

You can use the composer to issue quick requests directly in the browser. It looks like this:

Alchemy Composer in the dashboard

You can then fill in the fromAddress, withMetadata, categories, etc. fields and then hit "Send Request" to get a response. Then you can manually check the response.

This works well if the expected response is small and easy to parse, but if it isn't, then we should try option 2.

2. Write a script:

As shown in the Alchemy Transfers API documentation, you have the option of writing a Javascript fetch or axios call using json rpc to query for Transfers events. When the response comes back, you can add some logic to test for the specific events you're expecting.


To solve your actual root problem though, I noticed that the ENS transfer transaction you shared has 0xDce63CBee5E3f5d30729b777a11385B58b711a3c as the TO address, whereas in your alchemy_getAssetTransfers request, you set 0xDce63CBee5E3f5d30729b777a11385B58b711a3c to be the FROM address.

Once you make the switch, you can see (example Alchemy composer request) that the response will include your desired ENS transfer event:

{
  "blockNum":"0xe04a89" 
  "hash":"0xc97431eec5791405982b3d1873ed38062e5ea2542997aad9468efb28075bc88f"
  "from":"0x283af0b28c62c092c9727f1ee09c02ca627eb7f5"
  "to":"0xdce63cbee5e3f5d30729b777a11385b58b711a3c"
  "value":0.000353526461158219
  "erc721TokenId":NULL
  "erc1155Metadata":NULL
  "tokenId":NULL
  "asset":"ETH"
  "category":"internal"
  "rawContract":{...}
  "metadata":{...}
}

Hope that helps!

Related Topic