SX.js
SX.js is the official Typescript SDK to interact with Snapshot X. The SDK includes a client for Mana, the meta transaction relayer.
GitHub
https://github.com/snapshot-labs/sx-monorepo/tree/master/packages/sx.js
Quick start
Installation
Install the latest version of the beta release:
npm install @snapshot-labs/sx@betayarn add @snapshot-labs/sx@betabun add @snapshot-labs/sx@betaConfiguration
Clients
Everything happens thanks to the clients objects. Depending on the specific Space or Proposal setup, you may need to use a Transaction or Signature Client. This quick guide demonstrates how to easily set all of them up, both for Ethereum and StarkNet:
import { clients, evmSepolia } from '@snapshot-labs/sx';
const clientConfig = { networkConfig: evmSepolia }
const client = new clients.EthereumTx(clientConfig);
const ethSigClient = new clients.EthereumSig(clientConfig);import { clients } from '@snapshot-labs/sx';
import { Provider, constants } from 'starknet';
const ethUrl = 'https://rpc.snapshot.org/1';
const manaUrl = 'https://mana.pizza';
const starkProvider = new Provider({ sequencer: { network: constants.NetworkName.SN_GOERLI } });
const clientConfig = {
starkProvider,
manaUrl,
ethUrl
};
const client = new clients.StarkNetTx(clientConfig);
const starkSigClient = new clients.StarkNetSig(clientConfig);To learn more about StarkNet's Provider object, have a look here.
Usage
Cast a vote
Create a proposal
Update a proposal
Get voting power
Address' voting power depends on the strategy used. Below you can see an example of getting voting power for whitelist Voting strategy on Starknet.
Last updated
Was this helpful?