Off-chain, gasless governance voting with signed messages indexed by the Snapshot Hub. Spaces define voting strategies (token balance, delegation, NFT, quadratic) evaluated at a specified snapshot block.
- 01off-chain DAO voting
- 02gasless signature voting
- 03token-weighted polls
- 04quadratic / weighted strategies
- 05delegation
- pnpm add @snapshot-labs/snapshot.js
| Variable | Scope | Description |
|---|---|---|
| SNAPSHOT_HUB_URL | Client | Snapshot Hub endpoint. Use https://hub.snapshot.org for mainnet or https://testnet.hub.snapshot.org for staging. |
| SNAPSHOT_API_KEY | Server | Optional API key for higher GraphQL rate limits at https://hub.snapshot.org/graphql (sent via x-api-key header). |
Use Snapshot for gasless off-chain governance. Query proposals/votes from the GraphQL endpoint at `https://hub.snapshot.org/graphql` (e.g. `proposals(where: { space_in: [...] })`). For voting, instantiate `new snapshot.Client712(SNAPSHOT_HUB_URL)` and call `client.vote(web3, address, { space, proposal, type, choice, reason, app })` — `web3` is an ethers `Web3Provider`/v6 BrowserProvider. Resolve voting power per address with `snapshot.utils.getScores(space, strategies, network, addresses, blockNumber)`. Always pass the proposal's `snapshot` block when computing scores so totals match the on-screen result.
- ⚑Voting strategies are evaluated at the proposal's `snapshot` block — querying live balances will produce different numbers than the official tally.
- ⚑Votes are EIP-712 signed messages, not transactions; a connected wallet that only supports `personal_sign` (e.g. some smart-contract wallets without EIP-1271) cannot vote unless you enable Safe / EIP-1271 verification on the space.
- ⚑The public Hub GraphQL endpoint is rate-limited; production apps should request an API key and send it via the `x-api-key` header.
- ⚑Custom strategies run in Snapshot's sandbox and must be added to the strategy registry — you cannot ship arbitrary client-side scoring code.
- ⚑Snapshot X (the on-chain successor) uses a different SDK (`sx.js`) and Starknet/EVM contracts — do not mix it with classic Snapshot Hub APIs.