Skip to content

Commit 0618a5d

Browse files
sncast balance docs (#3818)
<!-- Reference any GitHub issues resolved by this PR --> Closes #2319 **Stack**: - #3818 ⬅ - #3817 ## Introduced changes Add docs for `sncast utils balance` ## Checklist <!-- Make sure all of these are complete --> - [x] Linked relevant issue - [x] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md`
1 parent dc1d11e commit 0618a5d

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Possibility to use [`starknet-devnet`](https://github.com/0xSpaceShard/starknet-devnet) predeployed accounts directly in `sncast` without needing to import them. They are available under specific names - `devnet-1`, `devnet-2`, ..., `devnet-<N>`. Read more [here](https://foundry-rs.github.io/starknet-foundry/starknet/integration_with_devnet.html#predeployed-accounts)
3232
- Support for `--network devnet` flag that attempts to auto-detect running `starknet-devnet` instance and connect to it.
3333
- Support for automatically declaring the contract when running `sncast deploy`, by providing `--contract-name` flag instead of `--class-hash`.
34+
- `sncast balance` command to fetch the balance of an account for a specified token.
3435

3536
## [0.50.0] - 2025-09-29
3637

docs/src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* [Outline](starknet/sncast-overview.md)
4949
* [`sncast` 101](starknet/101.md)
5050
* [Creating And Deploying Accounts](starknet/account.md)
51+
* [Account Balance](starknet/account-balance.md)
5152
* [Importing Accounts](starknet/account-import.md)
5253
* [Declaring New Contracts](starknet/declare.md)
5354
* [Deploying New Contracts](starknet/deploy.md)
@@ -136,6 +137,7 @@
136137
* [deploy](appendix/sncast/account/deploy.md)
137138
* [delete](appendix/sncast/account/delete.md)
138139
* [list](appendix/sncast/account/list.md)
140+
* [balance](appendix/sncast/balance.md)
139141
* [declare](appendix/sncast/declare.md)
140142
* [declare-from](appendix/sncast/declare_from.md)
141143
* [deploy](appendix/sncast/deploy.md)

docs/src/appendix/sncast.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* [create](./sncast/account/create.md)
77
* [deploy](./sncast/account/deploy.md)
88
* [delete](./sncast/account/delete.md)
9+
* [balance](./sncast/balance.md)
910
* [declare](./sncast/declare.md)
1011
* [declare-from](./sncast/declare_from.md)
1112
* [deploy](./sncast/deploy.md)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# `balance`
2+
Fetch balance of the account for specified token.
3+
4+
## `--token, -t <TOKEN>`
5+
Optional.
6+
Conflicts with: [`--token-address`](#--token-address)
7+
8+
Name of the token to check the balance for. Possible values
9+
- `strk` (default)
10+
- `eth`
11+
12+
## `--token-address, -d <TOKEN_ADDRESS>`
13+
Optional.
14+
Conflicts with: [`--token`](#--token)
15+
16+
Token contract address to check the balance for. Token needs to be compatible with ERC-20 standard.
17+
18+
## `--block-id, -b <BLOCK_ID>`
19+
Optional.
20+
21+
Block identifier on which balance should be fetched
22+
Possible values: `pending`, `latest`, block hash (0x prefixed string), and block number (u64).
23+
`pending` is used as a default value.
24+
25+
## `--url, -u <RPC_URL>`
26+
Optional.
27+
28+
Starknet RPC node url address.
29+
30+
Overrides url from `snfoundry.toml`.
31+
32+
## `--network <NETWORK>`
33+
Optional.
34+
35+
Use predefined network with public provider
36+
37+
Possible values: `mainnet`, `sepolia`.

docs/src/starknet/101.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ transaction: https://sepolia.starkscan.co/tx/0x[..]
6262

6363
</details>
6464

65+
Finally, you can check the account balance:
66+
67+
<!-- { "ignored": true } -->
68+
```shell
69+
$ sncast --account my_account balance --network sepolia
70+
```
71+
72+
<details>
73+
<summary>Output:</summary>
74+
75+
```shell
76+
Balance: [..] strk
77+
```
78+
</details>
79+
6580
Read more about accounts [here](./account-import.md)
6681

6782
> 💡 **Tip**
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Account Balance
2+
3+
`sncast` allows you to check the balance of your account using the `sncast balance` command.
4+
5+
## Basic Example
6+
7+
```shell
8+
$ sncast --account my_account balance --network devnet
9+
```
10+
11+
<details>
12+
<summary>Output:</summary>
13+
14+
```shell
15+
Balance: [..] strk
16+
```
17+
</details>
18+
19+
By default, it shows the balance in STRK tokens. Other possible tokens can be specified using the `--token` flag, read more [here](../appendix/sncast/balance.html#--token--t-token).
20+
21+
## Checking Balance of a Custom Token
22+
23+
You can check the balance of a custom token by providing the `--token-address` flag followed by the token's contract address.
24+
25+
> 📝 **Note**
26+
>
27+
> Token address must be a valid ERC-20 token contract.
28+
29+
<!-- { "ignored": true } -->
30+
```shell
31+
$ sncast --account user1 balance \
32+
--token-address <YOUR_TOKEN_ADDRESS> \
33+
--network sepolia
34+
```
35+
36+
<details>
37+
<summary>Output:</summary>
38+
```shell
39+
Balance: [..]
40+
```
41+
</details>
42+
43+
Read more about `sncast balance` command [here](../appendix/sncast/balance.md).

0 commit comments

Comments
 (0)