Skip to main content

Overview

Snapshot.js is an open source JavaScript client which comes with the core functions of the Snapshot’s offchain voting system. It was designed to work both in the browser and with Node.js. Snapshot.js Repository

Get started

Installation

Node.js To install Snapshot.js on Node.js, open your terminal and run:
Browser You can create an index.html file and include Snapshot.js with:

Development

Install dependencies
Build package

Usage

Base features

Init client

Cast a vote

Create proposal

Create or edit a space

Join a space

Utils

The below methods are sending a request to Score API. Same as Hub API it requires an API Key for higher usage limits. You can see we require it for the apiKey variable.If you already have an API Key for Hub API, you can reuse it for Score. In case you don’t have an API Key, follow the instructions here: API keys

getScores

Calculate voting power for a list of voters.

getVp

Retrieve voting power for a specific address using given strategies.

validate

Validate an address using a given validation strategy.

getProvider

Return a Ethers.js JsonRPCProvider connected to an archive node.