Canister Balances

Theory

In a manner similar to centralized exchanges, which take in deposited assets and keep track of user balances within their database, the Finny Protocol also accepts asset deposits and manages individual user balances within its canister using a structure known as the book balance. Please see #Depositing Assets and #Withdrawing Assets for instruction on sending and removing assets from the canister.

Practical Book Balance Viewing

- View Book Balance Candid

get_book_balance: (Token, principal) -> (opt nat) query;

Where token type is listed below

type Token = principal

- View Book Balance In Terminal Using dfx

dfx canister --network ic call z4viz-kiaaa-aaaal-qbxmq-cai get_book_balance '(principal <token_principal>, principal <your principal>)'

An Example:

We show an example to get the the book balance of ICP for an actual prinicipal

dfx canister --network ic call finrisk get_book_balance '(principal "z4viz-kiaaa-aaaal-qbxmq-cai", principal "e72ak-uu5s4-t3uba-ldsg5-yx7du-cn5t4-cvqoc-fkgoz-akjmp-3bljs-3qe")'

Last updated