githubEdit

Snapshot.js

The official JavaScript client for implementing Snapshot's functionality in other apps.

Overview

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

👉 Snapshot.js Repositoryarrow-up-right

Get started

Installation

Node.js

To install Snapshot.js on Node.js, open your terminal and run:

npm i @snapshot-labs/snapshot.js

Browser

You can create an index.html file and include Snapshot.js with:

<script src="https://cdn.jsdelivr.net/npm/@snapshot-labs/snapshot.js"></script>

Development

Install dependencies

yarn

Build package

Usage

Base features

Init client

Cast a vote

Create proposal

Create or edit a space

Join a space

Utils

circle-info

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.

Last updated

Was this helpful?