EXAMPLE 13 OF 16 · Intermediate
Build and email a multi-wallet balance sheet
Read a wallet list from CSV, flag low SOL balances, and save and email one complete token-account report.
Before you begin#
- Choose Solana mainnet and a working RPC route in runtime settings. These examples read live data; illustrative results below will differ.
- Select the Desktop runtime. Set absolute input and output paths for that machine; create the output directory before running.
- Follow email setup, select the saved connection on Email, and set emailTo to your own address.
- Download wallets.csv below, replace its placeholders, and set walletFile and reportPath in Globals. reportPath is the full destination filename.
Sample input files
Replace both address placeholders with public wallet addresses. Each address must be unique. min_sol is the native SOL alert threshold.
Walk through the workflow#
- Open file, Read file, and Parse CSV load the list. Code validates the rows and rejects duplicate addresses before any balance requests.
- Create file prepares a temporary report. Iterate sends each wallet through SOL balance and Token holdings.
- Code creates that wallet’s rows and calculates lowSol. If adds either LOW SOL or OK before Write file appends the rows.
- Iterate.done waits for every writing path. The completed rows are read, converted to CSV, saved to reportPath, and emailed once.
Read the balance sheet#
| label | asset | amount | status |
|---|---|---|---|
| Treasury | SOL | 1.5 | OK |
| Operations | SOL | 0.02 | LOW SOL |
These are illustrative rows. The real file also includes wallet and token-account addresses. A wallet below its own min_sol threshold gets LOW SOL on its rows. Token amounts are not added across unrelated mints, and this report does not calculate USD value.
Why a temporary file comes before the loop#
Iterate.done waits; it does not collect downstream results. Each item appends one JSON line to the shared temporary file. After done, Code reads those lines and Write CSV handles quoting and spreadsheet formula protection. Row order can differ because wallet reads can overlap.
Make one change#
Add a third wallet to the input CSV. Set one threshold above its current balance and another below it. Both If paths should be exercised, with one final email containing all completed rows.
If it does not match#
Replace every address placeholder and use a unique address per row. Missing folders cause Save file to fail. A failed wallet read stops the run rather than labelling an incomplete report as complete. Files are temporary until Save file succeeds.