What is the best way (or perhaps only way) to query db-sync for transactions involving a specific policy?

1 Answer 1


Since you mention "policy" it means you are only interested in multi asset transactions which are all contained in the ma_tx_out table.

However, you need to be aware that multiple assets can have the same policy. If this is what you want, the query would be:

select ma_tx_out.* from ma_tx_out inner join multi_asset
  on ma_tx_out.ident = multi_asset.id
  where multi_asset.policy = '\x....' ;

If instead you want all transaction for the same multi-asset then the query would be:

select * from ma_tx_out.ident = ? ;
  • 1
    Yes, all multi asset transactions are recorder in the ma_tx_out table. A multi_asset.id is actually a tuple of (policy, name) so that (policy1, name1) is different from (policy1, name2). I suspect that you are actually interested in the multi_asset.id rather than the policy. Aug 8, 2022 at 4:04
  • 1
    If you do select * from multi_asset ; you will see that each multi_asset row has a fingerprint which is probably what you should be using rather than policy. Aug 8, 2022 at 4:06
  • 1
    If you do select * from multi_asset order by policy limit 10 ; you will see that there are rows with the same policy field, but since they have different name fields, their fingerprint fields also differ. Aug 8, 2022 at 4:09
  • 1
    ...how can I use: where multi_asset.policy = '\x....' ; ...if the 'policy' column contains a byte array? Explicit conversion to a literal in the sql query itself? Thanks very much for all your responses Erik! I am learning! Aug 8, 2022 at 4:38
  • 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.