1

How can I query the last UTxO from an address on PostgreSQL (I used cardano-db-sync) like I would do using cardano-cli:

cardano-cli query utxo --address addr_test1vpm4uhupwxc4jjea6c6s5p0t80znlfr03xj4ewygnjtxd3cyjdv8x --testnet-magic 1097911063

I also want to know more information regarding this transaction like who sent, etc.

Thank you very much.

1
  • Hi, did you ever find an answer to his? I have the exact same query from cardano-db-sync but have not found a way to do this - thanks
    – simon
    Commented Jan 4, 2022 at 9:39

1 Answer 1

4

To get the basic utxo you would get from query utxo, you want a join from utxo_view to tx table.

SELECT * FROM utxo_view INNER JOIN tx ON tx.id = utxo_view.tx_id WHERE address = 'addr1...'

To get the list of txins sending the tx, you need to join that to tx_in and then rejoin that to the tx_out table and it will return a row for every output that's being used as an input, but usually at this point of complexity with SQL queries I start to throw for loops into my code.

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.