Installation
This guide covers installing@snapshot-labs/sx and setting up your development environment for building governance applications.
Package Installation
NPM
Yarn
PNPM
Package Information
- Package Name:
@snapshot-labs/sx - Current Version: 0.1.10
- License: MIT
- Repository: github.com/snapshot-labs/sx-monorepo
Importing the Package
The SDK uses ES modules by default and also provides CommonJS support.Import Everything
Import Specific Modules
Import Named Exports
Dependencies
The SDK has the following peer dependencies that you’ll need in your project:For EVM Chains
For Starknet
Additional Dependencies
The SDK automatically includes these dependencies:- @ethersproject/* - Core Ethereum utilities (ABI, addresses, signing, etc.)
- @openzeppelin/merkle-tree - Merkle tree utilities for whitelist strategies
- @shutter-network/shutter-crypto - Privacy-preserving voting support
- micro-starknet - Lightweight Starknet utilities
TypeScript Setup
The SDK is written in TypeScript and includes full type definitions.TypeScript Configuration
Ensure yourtsconfig.json has the following settings:
Type Imports
The SDK exports comprehensive types for all data structures:Using Types in Your Code
Network Configurations
The SDK provides pre-configured settings for all supported networks.EVM Networks
Starknet Networks
Offchain Networks
Custom Network Configuration
You can also create custom network configurations:RPC Endpoints
You’ll need RPC endpoints to interact with blockchain networks.Snapshot-Provided RPCs
Third-Party RPC Providers
You can also use services like:- Infura:
https://mainnet.infura.io/v3/YOUR_API_KEY - Alchemy:
https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY - Public RPCs: Various free options available
Mana Relayer URL
For gasless meta-transactions, you’ll need to configure the Mana relayer URL:Verification
Verify your installation by running a simple test:Next Steps
Now that you have the SDK installed, explore:- SDK Overview - Understand the package structure
- EVM Client - Start building with EVM chains
- Starknet Client - Work with Starknet
- Offchain Client - Implement gasless voting
- Examples - Browse code examples