forked from fetchai/cosmpy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improved landing page and fixed typo * made ATOM example \'work\' and added link to other chain info * added function to query all coin balances associated with an address * documentation for balance queries * more detailed balance querying instructions * update to docs to include multi-token queries * now passing (pedantic) formatting check * now passing isort test :( * updated readme/makefile and fixed typo * minor change * update makefile and readme * minor change Co-authored-by: ali <[email protected]>
- Loading branch information
1 parent
4e6d237
commit 4a66936
Showing
7 changed files
with
70 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
# ️Querying balance | ||
# ️Querying balances | ||
|
||
To query the balance of an account using a [`LedgerClient`](connect-to-network.md) object `ledger_client`: | ||
A [`LedgerClient`](connect-to-network.md) object can be used to query the balances associated with a particular address: | ||
|
||
```python | ||
balance = ledger_client.query_bank_balance('fetch1h2l3cnu7e23whmd5yrfeunacez9tv0plv5rxqy') | ||
address: str = 'fetch12q5gw9l9d0yyq2th77x6pjsesczpsly8h5089x' | ||
balances = ledger_client.query_bank_all_balances(address) | ||
``` | ||
|
||
`fetch1h2l3cnu7e23whmd5yrfeunacez9tv0plv5rxqy` in the above code is the account's address. | ||
This will return a `List` of `Coin` objects that contain `amount` and `denom` variables that correspond to all of the funds held at the address and their denominations. This list includes all natively defined coins along with any tokens transferred using the inter-blockchain communication ([IBC](https://ibcprotocol.org/)) protocol. | ||
|
||
By default, this will query the fee denomination that is in the network config associated with `ledger_client`. To explicitly specify the denomination value: | ||
```python | ||
>>> balances | ||
[Coin(amount='29263221445595384075', denom='afet')] | ||
``` | ||
|
||
It's also possible to query the funds associated with a particular denomination by calling | ||
|
||
```python | ||
balance = ledger_client.query_bank_balance('cosmos1h2l3cnu7e23whmd5yrfeunacez9tv0plv5rxqy', denom='uatom') | ||
``` | ||
balance = ledger_client.query_bank_balance(address, denom='afet') | ||
``` | ||
|
||
which will return the value of the (integer) funds held by the address with the specified denomination. If the `denom` argument is omitted the function will return the fee denomination specified in the `NetworkConfig` object used to initialise the `LedgerClient`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters