Getting Started
Step-by-step guide to building applications on Sonr with decentralized identity and cross-chain capabilities
Getting Started
Scope
This guide covers Sonr development setup, including environment configuration, CLI installation, local network deployment, and application creation. It introduces core concepts like DIDs, UCANs, and DWNs. This guide does not cover advanced deployment, production configurations, or validator operations—see specialized guides for those topics.
Audience
Developers building decentralized applications with identity features. System integrators connecting existing applications to Sonr. Prerequisites: Basic command line knowledge, familiarity with blockchain concepts, and experience with Go, Node.js, or TypeScript.
Summary
Sonr enables developers to build applications with decentralized identity (DIDs), user-controlled authorization (UCANs), and cross-chain capabilities (IBC). This guide walks through environment setup, CLI installation, and creating your first application. Start with local development, then explore browser integration or backend services.
Core Components
Sonr consists of three main components:
Sonr Node (snrd)
Cosmos SDK blockchain handling identity, transactions, and governance
Highway Proxy (hway)
HTTP bridge connecting web applications to the blockchain
Motr Enclave (motr)
WASM environment for secure vault operations and MPC
Each component serves a specific role:
- snrd: Processes transactions and maintains blockchain state
- hway: Translates HTTP requests to blockchain operations
- motr: Executes user vault logic in isolated environments
Development Setup
Install Prerequisites
Install required software:
- Go 1.21+: Blockchain development
- Node.js 18+: Client applications
- Docker: Local network deployment
# Verify installations
go version # go version go1.21.0
node --version # v18.0.0
docker --version # Docker version 24.0.0
Install Sonr CLI
Build and install the snrd
CLI:
# Clone repository
git clone https://github.com/sonr-io/sonr.git
cd sonr
# Install CLI
make install
# Verify installation
snrd version
The CLI provides commands for:
- Account management
- Transaction submission
- Chain queries
- Service registration
Start Local Network
Launch a development network:
# Start all components
make localnet-start
# Verify status
snrd status
This starts:
- snrd: Local blockchain node (port 26657)
- hway: HTTP proxy (port 8080)
- motr: Enclave service (port 9090)
Stop the network with:
make localnet-stop
Build Your First Application
Choose your development path:
Browser Integration
WebAuthn authentication and JavaScript SDK for web applications
Node.js/TypeScript
TypeScript SDK for server-side applications and React frontends
Go Backend
Direct blockchain integration for high-performance services
Quick Example
Create a simple identity check:
import { SonrClient } from "@sonr/sdk";
// Connect to local network
const client = await SonrClient.connect({
endpoint: "http://localhost:8080",
});
// Check if identity exists
const exists = await client.identity.exists("alice@example.com");
console.log(`Identity exists: ${exists}`);
Key Concepts
Understand these core concepts:
Decentralized Identity (DID)
W3C-compliant identifiers that users control. Each user has a unique DID like did:sonr:alice123
.
User Controlled Authorization (UCAN)
Capability-based permissions that users grant to services. Services request specific actions with time and scope limits.
Decentralized Web Nodes (DWN)
User vaults that store encrypted data and execute logic. Each vault runs in an isolated WASM environment.
Service Registration
Applications register with DNS verification and stake tokens. This creates trust without central authorities.
Common Tasks
Create Identity
Register users with WebAuthn
Request Permissions
Implement UCAN authorization
Store Data
Use DWN vaults for user data
Register Service
Add your app to the network
Next Steps
Ready to Build?
Quick Start: Follow the Browser Integration Guide to build your first app in 10 minutes.
Deep Dive: Explore the Architecture Documentation to understand system design.
Get Help: Join our Discord community for support and discussions.
Additional Resources
- API Reference - Complete API documentation
- Example Applications - Sample code and patterns
- GitHub Repository - Source code and contributions