How to get wallet that bough given asset

Another day, another API related question :smiley:

I’m trying to fetch the wallet that bough a given asset. I’ve figured that it can be done if I get all the trades for the given party_b_token_address, say this query. Next I take each a.order_id field and query it separately, like this. And here I can get the user field and that would be the wallet which bought the given asset for the given trade.

Questions:

  1. is it the intended use of the API?
  2. why don’t you add wallet / user to trades API response? Like:
      "a": {
        "order_id": 264784406,
        "token_type": "ERC20",
        "user": "buyer_wallet",
        "token_address": "0x7e77dcb127f99ece88230a64db8d595f31f1b068",
        "sold": "4000000000000000000"
      },
      "b": {
        "order_id": 264784794,
        "token_type": "ERC721",
        "token_id": "78620",
        "user": "seller_wallet",
        "token_address": "0x9e0d99b864e1ac12565125c5a82b59adea5a09cd",
        "sold": "1"
      },
  1. why don’t you add it to filled orders API? Like:
      "buy": {
        "type": "ETH",
        "user": "buyer_wallet"
        "data": {
          "token_address": "",
          "decimals": 18,
          "quantity": "413400000000000000",
          "quantity_with_fees": "413400000000000000"
        }
      }

Hi Enigo,

The Orders API should be able to help you with all your needs, the Trades API is a good way to see filled orders as is an aggregated view, however you will then need to query each order id to get the user who created that order. For each trade you myst have two filled orders a sell order and a buy order.

If you are looking for all the wallet addresses who purchased an NFT for a specific collection you need to use the listOrders endpoint API Reference | Immutable X Documentation and apply some filters. For example this query shows all the buy orders for ERC721 token type of the Illuvium land collection on sandbox:

https://api.sandbox.x.immutable.com/v1/orders?buy_token_type=ERC721&buy_token_address=0xb40a0dfa154713366e03efb12a325b9b8daecce7

An example of a query would be

Hey @Arthur
But orders API doesn’t provide the user(wallet) of the buyer, only seller. I want to have both wallets

Hi @Enigo there is an order for a seller and an order for a buyer

sellers order is selling erc721 and buying ETH
buyers order is selling ETH and buying ERC721

The user in each order is representative of the wallet taking part in the trade when the orders are matched, therefore you can list orders based on the params depending on which side you want to see.

So to see all buyers you need to match all filled orders where the buy side token type is erc721

Hey @Arthur
With that I’ll need to do two API calls - one for buyer and one for seller. I was wondering why don’t you provide this information in the same call given that you already have both buyer and seller nodes in the response

And rereading your answer I have a feeling that maybe my question wasn’t very clear. What I’m trying to do is to match a buyer and a seller of a given filled order. Not just to query all sell or buy events. Similarly how the Trade type of transaction is displayed on immutascan - it has two fields wallet_from and wallet_to. I’m trying to get wallet_to data. Hope it’s clear now

Hi @Enigo I understand the problem you are having, at the moment the only way around this issue is:

  • query via trades
  • use order endpoint x2 to return a list of trades one for buy, one for sell, then reconcile locally

I will certainly create a feature request for this in our customer voice portal.