as_of_ledger, so
the list does not change while you compute allocations or when people move
funds afterwards.
Set these once in your terminal. The sample values are real Testnet data, so
the read examples return real results.
as_of_ledger reads cover ledgers from read_view.bootstrap_ledger (5253887 on
Testnet) up to a few minutes behind the tip. For an older ledger, use a
snapshot job.
Check the ledger
One request shows the holder count at that ledger and confirms the history answers it:Build the allocation
The script reads every holder at the ledger, keeps accounts (contracts such as pools and vaults are left out), and splitsAIRDROP_TOTAL in proportion to
balance with integer math. It writes airdrop.csv.
BTC at ledger 5300000:
AIRDROP_TOTAL. Send the remainder (AIRDROP_TOTAL minus the sum of the
airdrop column) to the largest holder, or keep it. Keep the snapshot ledger
and the CSV together: anyone can recompute the list from the same ledger and
get the same rows.
Rules for past-ledger reads
- The answer is the state after the ledger closed.
supplyandas_of_closed_atarenullat a past ledger;holder_countis the count at that ledger. - A ledger after the latest applied one is
400. A ledger the history cannot answer exactly (beforebootstrap_ledger, or the last few minutes) is409 history_unavailable; the message says which. - Assets with more than 100,000 current holders return
409; use a snapshot job. - Publishable (
lum_pub_) keys cannot useas_of_ledger.
Older ledgers
For a ledger beforebootstrap_ledger, or a token with more than 100,000
holders, start a snapshot job. It returns up to the top 10,000 holders at any
ledger from 63 on. On Testnet the job is free (one request toward the daily
Testnet cap):
GET /snapshots/{id} until status is completed, then read
result.records. If result.truncated is true, the token had more than
10,000 holders at that ledger and the list holds only the largest 10,000: the
airdrop would leave out the smallest holders, so decide whether that is
acceptable before you distribute. See Historical snapshots for the
full job flow.
Credits
On Testnet these reads are free: the script above makes 2 requests toward the daily Testnet cap of 10,000. On Mainnet,as_of_ledger reads answer
501 not_implemented, so this recipe runs on Testnet only. See
Limits and credits.
Next
- Historical snapshots: past-ledger reads and jobs.
- Top holders of a token: the current ranking.
- Holders: filters and one holder’s rank.