Get the current balance for a user
- BacardenOP
Hi guys,
Still learning to understand the Ledger API.
My setup is that I have set up a super user who is basically doing the requests on behalf of my users using the Ledger API. I’ve done a similar operation to the
/v2/updatesendpoint, where I now get the transactions. The super user was granted the user right to act under a power of attorney, and I can now see the transactions.My next move, and this is what troubles me, I would like to get the current balance of a user. Is there any magic endpoint where I can get the current balance? I’ve read a little bit that I have to use the
/v2/updatesendpoint and then accumulate, but is this really my only option?I’m using the ledger
API v 3.4.10 - WallaceKelly 1
Updates If you are already subscribed to
/v2/updatesand storing the results, then yes, you could use that for summing the amount of holdings.PQS The Participant Query Store copies updates into a Postgres database. You can then write SQL queries to get all kinds of information, including balances.
Active Contracts In the general case, you can use the
/v2/state/active-contractsendpoint to get the UTXO holdings for a party. And then sum. (If you are using the TypeScript Wallet API, there is a function specifically for getting the collection of CIP-0056 holdings.)Canton Coin For CC specifically, the Scan Aggregates API provides a v0/holdings/summary endpoint.