Cardano - cardano-cli query utxo - get all utxo of an address

Hi, as the title, I’ve been wondering if cardano-cli has an ability to get all utxo based on given address.

I already tried

cardano-cli query utxo --address $(cat /path/to/addr) --testnet-magic 1097911063 --whole-utxo

But, it will return an error message

Invalid option '--whole-utxo'

I’m kinda confuse as on help it says, that --whole-utxo is available, but I do notice, that, it’s like an option we choose between --whole-utxo or --address or --tx-in.

I tried to dig some documents / forum and even on official github, but I found no clue to do so.
Mostly it pointed to install db-sync etc, but, tbh, I’m not a fan to install or use other additional components outside cardano-cli (db-sync, blockfrost, etc).
I prefer to use the core itself rather than rely on outside of core.

Been wonder if I missed something.

Thanks & Cheers.

Just leave out the --whole-utxo option. You don’t want all UTxOs (which would be too many, anyway), but only the ones for the one address.

Yeah, the help pretty clearly states that you should use exactly one of these three options. It also says for --whole-utxo: “(only appropriate on small testnets)”

Thanks for your replies. But, I kinda confuse with your answers, maybe my question a bit confusing too.

My question is - is there any command to pull all utxo only related to given address?

Not all or whole utxo on the entire Cardano blockchain, but, only related to given address.

If I did - cardano-cli query utxo --address $(cat /path/to/addr) --testnet-magic 1097911063
It only returns 1 last utxo, which not what I’m aiming for. I want to get all utxo (in/out) of that address.

The “U” in “UTxO” stands for “unspent”. So, it will only give you the transaction outputs that are still unspent.

And that is probably only one for your address.

What you seem to want is a complete transaction history. That is not possible with cardano-cli alone (because cardano-node does not save that information in an easily accessible way).

You would either need something like https://github.com/input-output-hk/cardano-db-sync or https://github.com/AndrewWestberg/cncli/blob/develop/USAGE.md#sync-command, which synchronise the history into a database that you can query (needs another large chunk of disk space), or you use an API like blockchain.io or koios.rest.

2 Likes

Ahh I see! Thank for your explanation! Seems I’m not really understand the concept of UTxO itself.
And yes, I was looking for transaction history for a given address.

Anyway, thanks a lot for your references & details!
All clear now, seems at the moment we indeed, need 3rd party (outside cardano cli / core).

Cheers!