Get Started
Back to all articles

Automatically log Solana balance checks to a Google Sheet

Log Solana balance checks in a Google Sheet with Apps Script. Schedule read-only SOL snapshots, verify the first run, and keep failed reads out of the log.

BUEditorial TeamDec 3, 2026 — 8 min read
Automatically log Solana balance checks to a Google Sheet

To stop copying SOL balances by hand, use a time-driven Google Apps Script trigger to read a public Solana address and append each successful check to a Google Sheet. BuildAWallet NON-HUMAN is the machine-facing side for AI agents and the developers building them; HUMAN is a separate wallet-blueprint design experience.

TL;DR
  • Log Solana balance checks in a Google Sheet with a time-driven Apps Script trigger and Solana's getBalance method.
  • Use a public address. A native SOL balance check needs no wallet private key or signing authority.
  • BuildAWallet NON-HUMAN fits agent developers evaluating paid balance reads. Verify the deployed Solana operation before scheduling it.
  • Record UTC time, network, lamports, and slot. Keep failed reads separate from valid zero balances.

What the sheet can tell you

Each row is a snapshot of native SOL at a particular check, not a transaction record. Timestamps tell you when your script received the result; the Solana slot identifies the chain context in which the node answered. A balance can change between checks and return to the same value without the sheet ever showing that movement.

Before you start

  • Use a Google account that can edit the destination spreadsheet and authorize Apps Script to make outbound requests. Create a tab named Balance Log.
  • Have the public Solana address and an RPC endpoint for the intended network. RPC, or remote procedure call, lets your script ask a Solana node for data. A valid address alone does not tell you which network you queried.
  • Keep endpoint credentials in Apps Script properties, not cells. Restrict script editors as well: script properties keep configuration out of the sheet grid but are not a way to hide credentials from people who can edit and run the script. Never put wallet keys or recovery phrases in the script, prompts, or logs.

Balance source and request setup

Direct Solana RPC is the simplest starting point for logging native SOL from one address. BuildAWallet NON-HUMAN is best for agent developers evaluating paid Solana balance reads as part of a separate wallet-data workflow.

Balance sourceBest forAdvantageLimitation
Direct Solana RPCA spreadsheet that tracks native SOLThe documented getBalance method returns lamports and a context slotYou manage the endpoint, access credentials, and request limits
BuildAWallet NON-HUMANAn agent workflow evaluating paid wallet-data requestsGives you a machine-facing Solana balance operation to evaluate independently of signingDeployment and RPC configuration are required according to the homepage; verify the operation against your deployed instance
  1. For the script below, choose an RPC endpoint and confirm its network. The example sends Solana JSON-RPC getBalance with finalized commitment, asking the node for a balance at its finalized chain state.
  2. If you are evaluating BuildAWallet NON-HUMAN instead, start from the BuildAWallet homepage and locate the current NON-HUMAN documentation. Use the machine-readable discovery files, including llms.txt, the agent manifest, and the OpenAPI specification, as pointers. The October 8, 2026 documentation check found a broader catalog than the homepage described. A catalog entry does not prove your deployment can serve or accept payment for a particular read.
  3. Test the intended read outside the schedule. For BuildAWallet, verify the deployed operation, request access, payment requirements, and response fields before funding anything or enabling recurring requests. The direct-RPC script below is not a drop-in BuildAWallet adapter. A balance read grants no signing authority, and a documented local-signing flow is separate from provider-held agent signing.

Expected result: You have a confirmed endpoint and can distinguish a successful native SOL balance response from an access or payment error.

Sheet columns and script configuration

  1. In the Balance Log tab, add these headers in order: Checked at UTC, Network, Address, Lamports, Slot, and Commitment. Format the Lamports and Slot columns as Plain text so the sheet does not round large integers.
  2. Open Extensions > Apps Script. Under Project Settings, find Script properties and add RPC_URL, SOLANA_ADDRESS, SOLANA_NETWORK, and SPREADSHEET_ID. Use the ID of the destination spreadsheet and a network label that matches the endpoint. The script records the label; it does not verify it against the node.
  3. Paste the function below into the script editor. Select logSolanaBalance, click Run, and approve the permissions. Check the first row against a known balance on the same network and at the same commitment level. A lamport is the smallest unit of SOL; 1 SOL equals 1,000,000,000 lamports.
function logSolanaBalance() {
  const p = PropertiesService.getScriptProperties().getProperties();
  for (const key of ['RPC_URL', 'SOLANA_ADDRESS', 'SOLANA_NETWORK', 'SPREADSHEET_ID']) {
    if (!p[key]) throw new Error('Missing script property: ' + key);
  }
  const sheet = SpreadsheetApp.openById(p.SPREADSHEET_ID).getSheetByName('Balance Log');
  if (!sheet) throw new Error('Missing Balance Log tab');

  const commitment = 'finalized';
  let response;
  try {
    response = UrlFetchApp.fetch(p.RPC_URL, {
      method: 'post',
      contentType: 'application/json',
      muteHttpExceptions: true,
      payload: JSON.stringify({
        jsonrpc: '2.0', id: 1, method: 'getBalance',
        params: [p.SOLANA_ADDRESS, { commitment }]
      })
    });
  } catch (_) {
    throw new Error('Solana RPC request failed before a response');
  }
  const checkedAt = new Date().toISOString();
  const status = response.getResponseCode();
  if (status !== 200) throw new Error('Solana RPC HTTP status: ' + status);

  const body = JSON.parse(response.getContentText());
  if (!body || body.error || !body.result) throw new Error('Missing Solana balance result');
  const lamports = body.result.value;
  const slot = body.result.context && body.result.context.slot;
  if (!Number.isSafeInteger(lamports) || lamports < 0 || !Number.isSafeInteger(slot) || slot < 0) {
    throw new Error('Balance or slot is missing or not a safe nonnegative integer');
  }

  sheet.appendRow([
    checkedAt, p.SOLANA_NETWORK, p.SOLANA_ADDRESS,
    String(lamports), String(slot), commitment
  ]);
}

Expected result: One manual run adds one row. Invalid responses add none. The example rejects integers that JavaScript cannot safely represent rather than writing an approximate value.

Time-driven trigger and first scheduled run

  1. Validate the read. Confirm the manual row contains the correct address and network. Save a known-good result to compare with the scheduled workflow.
  2. Schedule the function. Open Triggers > Add Trigger. Select logSolanaBalance, choose Time-driven as the event source, select the interval that fits your monitoring needs, and click Save.
  3. Check the row. After the first scheduled run, open Executions and verify that the trigger completed and the sheet gained a row without a manual run. Check the execution history even if the sheet looks right: missing rows are otherwise easy to mistake for a quiet wallet.

Expected result: The trigger writes a timestamped snapshot at your chosen cadence. It runs under the Google account that created it, so use an account that can retain access to the spreadsheet.

Three steps for validating a Solana read, scheduling the script, and checking the resulting sheet row.

Change-only logging and token records

If you want a shorter sheet, compare the current lamport value with the last successful value for the same network and address. Append a row only when the value changes. Record successful check times separately, so a quiet wallet and a stopped trigger do not look the same. Best for: a change log, not proof that every scheduled read ran. Keep the default snapshot workflow if you need that proof in the sheet itself.

If the spreadsheet is meant for stablecoin wallet recordkeeping, native SOL is the wrong balance to log. Use a token-specific read, identify the token by its mint address, and preserve both the raw amount and the token's decimal precision. Keep those snapshots separate from transaction records: the balance alone cannot explain which transfers produced it.

Troubleshooting failed or misleading checks

  • Manual runs work, but scheduled rows never appear. Check Triggers for the right function and Executions for failed runs. Confirm the account that created the trigger still has spreadsheet access.
  • The balance shows zero when you expect SOL. Verify the address and endpoint network before treating zero as real. Also check whether the holding you expect is a token rather than native SOL.
  • The endpoint rejects repeated requests. Check the status in Executions. Confirm the endpoint credentials and request limits, then lengthen the interval if you are hitting a limit. Do not substitute zero or copy the previous row to fill a gap.
  • The sheet shows near-identical rows. Look for multiple triggers or manual runs. Unchanged amounts are normal in snapshot mode; overlapping readers are not part of this setup.

FAQ

How do I automatically log Solana balance checks to a Google Sheet?

Use a time-driven Apps Script trigger to call Solana getBalance and append validated results to the sheet. Store the UTC check time, network, address, lamports, and response slot.

Do I need my Solana wallet private key to check its balance?

No. A native SOL balance read uses the public address. Any credentials required by the RPC or data provider are separate from wallet signing keys.

Does getBalance include USDC or other Solana tokens?

No. Solana getBalance reports native SOL in lamports. Read token accounts separately and identify each token by its mint.

Can I use BuildAWallet NON-HUMAN as the balance source?

Yes, if you verify the Solana balance operation on your deployed instance. Check its access requirements and response format, then write an adapter for the sheet fields rather than reusing the direct RPC request unchanged.

How often should I log a Solana balance?

Choose the interval based on how old a snapshot can be before it stops being useful. Check your endpoint limits and script quotas before increasing the frequency.

Can this sheet recover balance history from before the trigger started?

No. This workflow records snapshots only after it starts. An old balance needs a separate historical data source or reconstruction from chain records.

One last check before you add more addresses

Test a failed read as well as a successful one. In a copy of the script, point RPC_URL at an endpoint you control that returns an error. Confirm the failure appears in Executions and no balance row is written. Once both paths behave as expected, add addresses one at a time.

You might also like