---
id: BI0168
title: "Vote cost estimator"
url: https://carbium.sh/library/blockchainideas/vote-cost-estimator
collection: Blockchain ideas
category: DAO and treasury
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Vote cost estimator

A vote is a transaction, so it costs a signature fee, and a vote that opens a record account also locks rent. This estimator reads both from Carbium and checks the wallet's balance.

## Who asks this

Most people who ask this have just pressed a vote button and watched a SOL balance fall. They want to know what the drop is, whether any of it comes back, and how much a wallet needs before its first vote. A treasury lead asks the same question for a whole member list, since every new voter pays for the same parts.

This board answers with three numbers and one yes or no: the signature fee, the rent for the record the vote opens, the total for a first vote, and whether the wallet holds that much. It is read-only. It never signs, sends or holds a key, so a DAO can run it against a member's public address before the member votes. The [DAO treasury dashboard](https://carbium.sh/library/blockchainideas/dao-treasury-dashboard) reads the same kind of balances for a whole treasury.

## Where the SOL goes

A vote is a Solana transaction, and each transaction pays for the work it asks of the network. Two parts make up the cost of a first vote, and a third is optional.

| Part | Size | Comes back? |
|---|---|---|
| Signature fee | 5,000 lamports per signature in standard Solana fees, read from the network | No, it is spent |
| Rent for the record | the rent-exempt minimum for the record's byte size | Yes, when the account is closed |
| Priority fee | set by the sender per compute unit, on top of the base fee | No, and not priced here |

Rent can be the larger part, since a record keeps its data for as long as the account exists. The [rent-exempt minimum calculator](https://carbium.sh/library/howsolana/rent-exempt-minimum-calculator) prices the same figure for any account size.

Where a program keeps one record per voter and proposal, a second vote on the same proposal pays the signature fee alone. Check the program's own rules for that before you give a member the number.

## How the estimate is built

1. Resolve a payer. Use `--payer` when it is given. Otherwise read the newest signature on the token program, load it with [getTransaction](https://carbium.sh/docs/rpc) and take its first account key.
2. Build a legacy message with one signer, the payer, and no instructions. The blockhash comes from getLatestBlockhash, so the probe is current.
3. Price the message with getFeeForMessage at confirmed commitment. The base fee depends on the signature count alone.
4. Read the rent-exempt minimum for `--size` bytes with getMinimumBalanceForRentExemption.
5. Read the payer's balance with getBalance and print whether it covers the fee and the rent.

`main.ts` (run: `CARBIUM_KEY=<YOUR_KEY> node main.ts --size 165`)

```ts
// BI0168 · Vote cost estimator
// https://carbium.sh/library/blockchainideas/vote-cost-estimator
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import {
  address,
  createDefaultRpcTransport,
  createSolanaRpcFromTransport,
  getBase58Encoder,
  isSolanaError,
  SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR,
} from "@solana/kit";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium API key.");
  process.exit(1);
}
const flag = (name: string): string | undefined => {
  const i = process.argv.indexOf(name);
  return i > 0 ? process.argv[i + 1] : undefined;
};
// Bytes of the record the vote opens. 165 is an SPL token account, a stand-in size; pass your program's real size.
const SIZE = Number(flag("--size") ?? 165);
// The token program is busy, so its newest signature names a payer when no --payer is given.
const TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

async function payer(): Promise<string> {
  const given = flag("--payer");
  if (given) return given;
  const [newest] = await rpc.getSignaturesForAddress(address(TOKEN_PROGRAM), { limit: 1 }).send();
  if (!newest) throw new Error("no recent signature on the token program");
  const tx = await rpc
    .getTransaction(newest.signature, { commitment: "confirmed", encoding: "json", maxSupportedTransactionVersion: 1 })
    .send();
  if (!tx) throw new Error("the newest signature is not readable yet; run again");
  return tx.transaction.message.accountKeys[0];
}

function report<T>(name: string, r: PromiseSettledResult<T>): T | undefined {
  if (r.status === "fulfilled") return r.value;
  const e = r.reason;
  if (isSolanaError(e, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR) && e.context.statusCode === 429) {
    console.error(`${name}: rate limited (429), run again after a second`);
  } else console.error(`${name} failed: ${e instanceof Error ? e.message : String(e)}`);
  return undefined;
}

async function main(): Promise<void> {
  const who = await payer();
  const { value: latest } = await rpc.getLatestBlockhash().send();
  // A legacy message with one signer (the fee payer) and no instructions. The base fee depends on the signature count alone.
  const message = Buffer.concat([
    Buffer.from([1, 0, 0, 1]),
    Buffer.from(getBase58Encoder().encode(who)),
    Buffer.from(getBase58Encoder().encode(latest.blockhash)),
    Buffer.from([0]),
  ]).toString("base64");
  const [fee, rent, balance] = await Promise.allSettled([
    rpc.getFeeForMessage(message as Parameters<typeof rpc.getFeeForMessage>[0], { commitment: "confirmed" }).send(),
    rpc.getMinimumBalanceForRentExemption(BigInt(SIZE)).send(),
    rpc.getBalance(address(who)).send(),
  ]);
  const feeLamports = report("fee", fee)?.value ?? null;
  const rentLamports = report("rent", rent);
  const lamports = report("balance", balance)?.value;
  console.log(`payer ${who}`);
  console.log(`signature fee: ${feeLamports ?? "unknown"} lamports for one signature`);
  console.log(`rent for ${SIZE} bytes: ${rentLamports ?? "unknown"} lamports, returned when the account closes`);
  if (feeLamports !== null && rentLamports !== undefined && lamports !== undefined) {
    const total = feeLamports + BigInt(rentLamports);
    console.log(`first vote that opens a record: ${total} lamports; wallet holds ${lamports}`);
    console.log(lamports >= total ? "wallet covers it" : "wallet is short");
  }
}

main().catch((e: unknown) => {
  console.error(e instanceof Error ? e.message : String(e));
  process.exit(1);
});
```

The message is a price probe, and nothing in the code signs it. A real vote brings its own instructions and signers. Because the base fee is linear in signatures, a vote with two signers costs twice the base fee, and the reader can scale the printed figure. Pass `--size` as your program's record size. The default 165 is only the size of an SPL token account, chosen so any reader can check it.

## What a run costs

Each run makes two lookups when no payer is given: getSignaturesForAddress and getTransaction, each 50 cells per call. On Free their rate is 0.24 req/s, and on Dev it is 1.2 req/s.

[Limits are per account](https://carbium.sh/docs/limits), so a key used by other tools draws on the same budget. One run from a Free key stays inside the rate as long as it is not repeated within a second. A Free key over its network's shared budget gets 429 with a retry-after hint, so a busy hour can refuse a run that would pass at a quiet time.

## Where it ends

- The estimate covers the base signature fee and the rent. The priority fee moves with network demand and with the compute units the vote uses, so it is left out. Add it from the sender's own setting when the vote is sent.
- The probe message has no instructions. A governance program's real vote can need more signers, more accounts and a larger record. Read the record size from that program's account layout and count the signers yourself.
- Since the Alpenglow switch, mainnet blocks carry no vote transactions. This estimate covers a governance vote that a member sends as a transaction. It says nothing about validator consensus votes.
- The payer lookup reads the newest token-program signature. [getSignaturesForAddress](https://carbium.sh/docs/rpc) on Carbium reaches back 30 days at most, and its pages reach below the validator's ledger floor, so a signature it lists can answer null from getTransaction. Pass `--payer` when the lookup returns nothing usable.
- Mainnet carries v1 transactions. The code asks getTransaction with maxSupportedTransactionVersion set to 1, since without it the call answers -32015 for a v1 transaction.
- Rent comes back only when the program closes the record and returns the lamports. A record kept forever keeps its rent locked, and the estimate cannot tell which case a program uses.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| getFeeForMessage returns no value. | The blockhash may have expired, or the probe message is malformed. Run again, since each run takes a fresh blockhash. |
| The payer lookup says the newest signature is not readable yet. | It is newer than the node's confirmed view. Run again in a few seconds, or pass `--payer` with a wallet you know. |
| A call answers 429. | The call went over its req/s limit. Wait a second and run again, and check what else on the key is calling, because the budget is shared across the account's keys. |
| The total looks low for a real vote. | The probe has one signer and no instructions. Multiply the fee by the real signer count and add the priority fee the sender sets. |
| The rent figure does not match the program. | The size is the cause. Set `--size` from the program's account layout and run again. |
| The run prints wallet is short. | The payer holds less than the fee and rent. Add SOL to the wallet before the vote, then run again to see the new balance. |

## Questions

### Why does voting cost SOL if a vote is only a yes or a no?

The vote is still a transaction, and the network charges a fee per signature for every transaction. When the vote also opens a record account, that account must hold rent-exempt SOL, which stays locked until the account is closed.

### Do I get the SOL back after a vote?

The signature fee is spent and does not return. The rent returns only when the program closes the record and pays the lamports back to the payer.

### Does this estimate cover validator votes?

No. Since the Alpenglow switch, mainnet blocks carry no vote transactions, and this entry prices a governance vote that a member sends.

### Can a DAO run the check for every member?

Yes. Loop over the member list and call getBalance and getFeeForMessage for each address, paced under the plan's req/s so the loop does not draw 429 responses.

## Related

- [DAO treasury dashboard](https://carbium.sh/library/blockchainideas/dao-treasury-dashboard) (Blockchain ideas, BI0010)
- [Rent-exempt minimum calculator](https://carbium.sh/library/howsolana/rent-exempt-minimum-calculator) (How to use Solana, HS0020)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
