@peeramid-labs/sdk
v3.16.3
Published
Peeramid Labs JavaScript SDK and CLI tools for building your community
Readme
SDK
This is SDK for use with Rankify game. You can ease interaction with smart contracts.
Installation
# Using npm
npm install @peeramid-labs/sdk
# Using yarn
yarn add @peeramid-labs/sdk
# Using pnpm
pnpm add @peeramid-labs/sdkCLI Usage
The SDK includes a command-line interface for interacting with Peeramid contracts:
# Set up environment variables
export RPC_URL="your-rpc-url"
export PRIVATE_KEY="your-private-key"
# List available commands
peeramid --help
# Examples:
peeramid distributions list
peeramid fellowship create
peeramid instances list
peeramid multipass domains createDevelopment
Prerequisites
Before setting up the local development environment, ensure you have the following installed:
Node.js and pnpm
# Using homebrew brew install node npm install -g pnpmFoundry (for Anvil)
curl -L https://foundry.paradigm.xyz | bash foundryuptmux
# Using homebrew brew install tmux
Local Development Setup
To set up your local development environment:
Create your environment file:
mkdir -p .secrets cp samples/<network>.env.example .secrets/<network>.envThen edit
.envto set your local repository paths.Set the required environment variables:
export RANKIFY_CONTRACTS_PATH="/path/to/rankify/contracts" export MULTIPASS_PATH="/path/to/multipass"Make the setup script executable:
chmod +x scripts/deploy-contracts.sh
Possible CLI arguments for deployment:
./scripts/deploy-contracts.sh --clean #rebuilds and redeploys contracts and all upstream deps
./scripts/deploy-contracts.sh --indexer #launches envio indexer right after contracts (requires ../envio checked out)- Run the setup script:
./scripts/deploy-contracts.sh <network> --clean # set last argument to clean the deployments & artifacts
This will:
- Start a local Anvil development network in a tmux session (for localhost network)
- Install dependencies for all repositories
- Run local deployment scripts (
playbook/utils/deploy-to-local-anvil.sh) in each repository - Set up local pnpm links between packages
The script uses a fixed mnemonic for consistent addresses across runs.
Managing Anvil
- View Anvil logs:
tmux attach -t anvil - Detach from logs: Press
Ctrl+BthenD - Stop Anvil:
tmux kill-session -t anvil
Setting requirements on game creation
To set requirements on game creation, you can use the game create command with the --requirement flag. For example:
peeramid game create ... --requirement ./req.jsonworks with following JSON file structure:
{
"ethValues": {
"have": "1",
"lock": "2",
"burn": "3",
"pay": "4",
"stake": "5"
},
"contracts": [
{
"contractAddress": "0x98fBE64861B331674e195E1A0b2fA303324c83e1",
"contractId": 1,
"contractType": 2,
"contractRequirement": {
"have": { "data": "0x00", "amount": "100000000000000" },
"lock": { "data": "0x00", "amount": "100000000000000" },
"burn": { "data": "0x00", "amount": "100000000000000" },
"pay": { "data": "0x00", "amount": "100000000000000" },
"stake": { "data": "0x00", "amount": "100000000000000" }
}
}
]
}Documentation
The SDK comes with comprehensive API documentation generated using TypeDoc. The documentation is automatically generated during the package build process and is included in the npm package.
Generating Documentation
To generate the documentation locally:
pnpm run docsThis will create a docs directory with the generated documentation.
For development, you can use the watch mode:
pnpm run docs:watchAccessing Documentation
- Local Development: Open
docs/index.htmlin your browser after generating the documentation - Published Package: Documentation is available through the npm package page
