EXAMPLE 14 OF 16 · Advanced
Report SOL changes across multiple wallets
Compare each wallet with its previous run, report exact lamport changes, and keep a new baseline in workflow State.
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.
- Use the same workflow and runtime between runs. Set walletFile, reportPath, and emailTo. The first run establishes the baseline.
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#
- Load and validate the wallet list, then read SOL for each wallet.
- Get State reads a key containing the public wallet address. Code uses BigInt to compare raw lamport strings without rounding.
- If includes new or changed balances in the report. That path writes a row and then saves the current balance; unchanged wallets produce no row.
- After Iterate.done, a nonempty report is saved and emailed. With no changes, the workflow finishes with a No SOL changes message.
Compare three runs#
On a new workflow, every wallet is marked baseline and deltaLamports is empty. Run again with unchanged balances: no email is sent. If a balance later rises from 1000000000 to 1250000000 lamports, its row reports a delta of 250000000.
Why use raw strings and BigInt#
Decimal display numbers can lose precision. Subtraction happens with BigInt, then toString returns a JSON-compatible value. The snapshot includes native SOL only; a token transfer can occur without the same change in SOL.
What the saved baseline means#
State is updated after that wallet’s report row is written, before final file delivery. It records an observed balance, not a delivered-email receipt. If saving or email later fails, inspect that run’s rows before retrying; the same balance may now be unchanged. Run one copy on one runtime when learning this behavior.
Make one change#
Import a fresh copy and compare its baseline with the original. Then change the report subject. To start a wallet’s baseline over, use Delete State with its exact sol:ADDRESS key. Changing networks also requires a fresh baseline.