1

It seems like a simple question, but I was struggling to find the answer.

I am trying to get information of Cardano blockchain from cexplorer database.

Given an address such as 'addr1w9742z4fewans7ry6cjp95pc4ecv7y54cx298lp5qfw7s9gv8ukrj' How can I get all the assets currently belonging to this address. (the assets are minted tokens, nfts, amount of ADA, etc)

Thank you very much.

1 Answer 1

2

For ADA balance, you can use the utxo_view table like this:

select * from utxo_view where
  address = 'addr1w9742z4fewans7ry6cjp95pc4ecv7y54cx298lp5qfw7s9gv8ukrj' ; 

If you look at how utxo_view is defined, you can probably copy and tweak it so you are looking at the relevant multi_asset tables instead.

4
  • Thanks for your question. I understand that the utxo_view is for querying the number of ADA. But I still do not get how to get other assets. Could you please provide a rough idea of how to get other assets?
    – cdt
    Aug 31, 2022 at 22:08
  • You will need to create a new SQL view (call it say ma_utxo_view) that uses the multi asset tables rather than the main tables. Aug 31, 2022 at 22:26
  • 1
    I guess something like this, right? select multi_asset.name::text, ma_tx_out.*, tx_out.* from public.multi_asset, public.tx_out, public.ma_tx_out where multi_asset.id = ma_tx_out.ident and tx_out.id = ma_tx_out.tx_out_id and tx_out.address ='addr1w9742z4fewans7ry6cjp95pc4ecv7y54cx298lp5qfw7s9gv8ukrj'
    – cdt
    Sep 1, 2022 at 14:05
  • That seems correct, but I would suggest that you create a view (ie something like the utxo_view) and submit that via GH so I can add that as to the default db-sync distribution. Sep 7, 2022 at 6:50

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.