Files
sonr/cmd/snrd
40eadc995e Feat/1285 es ucan formatting (#1302)
* feat: Add Enclave Usage Examples

* feat(es/ucan): Add comprehensive integration tests

- Create integration.test.ts with full UCAN token lifecycle testing
- Cover end-to-end token creation, parsing, and validation
- Test capability attenuation and delegation chains
- Validate multi-algorithm support and timestamp scenarios
- Implement error recovery and performance test scenarios

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>

* No commit suggestions generated

* No commit suggestions generated

* chore: Remove migrated components and add migration documentation

Removed all code and references for components that have been moved to separate repositories:

**Moved to sonr-io/hway:**
- bridge/ - HTTP service with OAuth2/OIDC/WebAuthn handlers
- cmd/hway/ - Highway service binary
- internal/migrations/ - PostgreSQL schema migrations

**Moved to sonr-io/motr:**
- cmd/motr/ - Motor worker service (WASM vault operations)
- cmd/vault/ - Vault CLI tool
- crypto/ - Comprehensive cryptographic library
- packages/ - TypeScript SDK packages (es, sdk, ui, com, pkl)
- web/auth/ - Authentication web application
- web/dash/ - Dashboard web application

**Updated Configuration:**
- Makefile: Removed build/test/release targets for moved components
- CLAUDE.md: Simplified to focus on core blockchain components
- devbox.json: Removed scripts for moved services
- docker-compose.yml: Removed hway, postgres, redis, auth, dash services
- .github/scopes.yml: Removed CI scopes for migrated components
- .goreleaser.yml: Updated release configuration

**Added Migration Documentation:**
- MIGRATE_HWAY.md: Comprehensive Highway service architecture and migration guide
- MIGRATE_MOTR.md: Comprehensive Motor/Worker/Vault architecture and migration guide

These migration documents provide complete context for setting up the new repositories including architecture diagrams, component breakdowns, API documentation, and migration checklists.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* No commit suggestions generated

* chore: Remove contracts references and documentation

Removed all references to the contracts directory that was migrated to a separate repository.

**Changes:**
- .gitignore: Removed contract-specific ignore patterns for DAO and wSNR contracts
- .gitignore: Removed hway and motr binary references (already migrated)
- .rgignore: Removed contracts, chains, and crypto directory references
- docs/reference/contracts/: Removed DAO.mdx and wSNR.mdx documentation files

This completes the cleanup of migrated components from the repository.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add crypto library migration documentation

Added comprehensive migration documentation for the crypto library that was
moved to sonr-io/crypto repository. This documentation provides complete context
for understanding the cryptographic primitives and protocols used throughout
the Sonr ecosystem.

## Key Documentation Added

### MIGRATE_CRYPTO.md
Complete documentation of the crypto library covering:

**Core Cryptographic Primitives**
- Elliptic curve implementations (Ed25519, Secp256k1, P-256, BLS12-381, Pallas/Vesta)
- Native curve arithmetic with optimized field operations
- Pairing-friendly curves for BLS signatures

**Multi-Party Computation (MPC)**
- MPC enclave for vault key generation and management
- Threshold cryptography (TECDSA, TED25519 with FROST protocol)
- Distributed Key Generation (DKG) via Gennaro and FROST protocols
- Secret sharing schemes (Shamir, Feldman VSS, Pedersen VSS)

**Digital Signature Schemes**
- BLS signatures with aggregation support
- BBS+ signatures for selective disclosure
- Schnorr signatures (standard and Mina/NEM variants)
- ECDSA with deterministic nonce generation

**Zero-Knowledge Proofs**
- Bulletproofs for range proofs
- Inner Product Arguments (IPA)
- Batch verification support

**Advanced Cryptographic Protocols**
- Cryptographic accumulators for set membership proofs
- Paillier homomorphic encryption
- Oblivious Transfer (OT) protocols
- Verifiable Random Functions (VRF)

**Key Management & Identity**
- DID key management with multi-chain support
- Multi-algorithm public key handling
- Wallet address derivation (Bitcoin, Ethereum, Cosmos, Solana, etc.)

**UCAN Integration**
- User-Controlled Authorization Networks
- Capability delegation and attenuation
- JWT-based capability tokens
- MPC-enabled UCAN signing

**Security Utilities**
- AEAD encryption (AES-GCM, AES-SIV)
- Argon2 key derivation
- ECIES encryption
- Secure memory handling

### MIGRATE_MOTR.md Updates
Updated Motor migration documentation to clarify that the crypto library
is now a separate external dependency at github.com/sonr-io/crypto v1.0.1

## Repository Context

The crypto library has been successfully migrated to its own repository
and is published as a Go module. It serves as the foundational cryptographic
layer for:
- Sonr blockchain (snrd) - DID signatures, vault operations
- Highway service (hway) - UCAN token signing, WebAuthn
- Motor/Worker (motr) - MPC vault operations, threshold signatures

## Integration Impact

All Sonr ecosystem components now depend on the external crypto library:
```go
require github.com/sonr-io/crypto v1.0.1
```

The migration enables independent versioning and maintenance of cryptographic
primitives while maintaining security and compatibility across the ecosystem.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* No commit suggestions generated

* No commit suggestions generated

* No commit suggestions generated

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-10 11:47:18 -04:00
..
2025-10-03 14:45:52 -04:00
2025-10-03 14:45:52 -04:00
2025-10-03 14:45:52 -04:00
2025-10-10 11:47:18 -04:00
2025-10-03 14:45:52 -04:00
2025-10-03 14:45:52 -04:00
2025-10-03 14:45:52 -04:00

snrd - Sonr Blockchain Daemon

snrd is the command-line interface and daemon for the Sonr blockchain network. It provides a comprehensive set of tools for running nodes, interacting with the network, managing identities, and performing blockchain operations.

Overview

Sonr is a Cosmos SDK-based blockchain that combines decentralized identity (DID), WebAuthn authentication, and IPFS storage capabilities. The snrd daemon serves as the primary interface for:

  • Running blockchain nodes (validators, full nodes)
  • Managing decentralized identities and credentials
  • Performing wallet operations and transaction signing
  • Interacting with IPFS for decentralized storage
  • Querying blockchain state and submitting transactions

Installation

Prerequisites

  • Go 1.24+
  • Docker (for IPFS operations)
  • Git

Build from Source

# Clone the repository
git clone https://github.com/sonr-io/sonr.git
cd sonr

# Install the binary
make install

# Verify installation
snrd version

Architecture

The snrd binary is built on the Cosmos SDK v0.50.13 and includes:

  • Cosmos SDK modules: Standard blockchain functionality (auth, bank, staking, etc.)
  • Custom modules:
    • x/did: W3C DID specification with WebAuthn support
    • x/dwn: Decentralized Web Node for data storage
    • x/svc: Service management and domain verification
    • x/ucan: User-Controlled Authorization Networks
  • EVM compatibility: Ethereum Virtual Machine support via Evmos
  • IPFS integration: Decentralized storage for large data objects

Network Configuration

  • Address prefix: idx (Bech32 encoded addresses)
  • Coin type: 60 (BIP44 - Ethereum compatible)
  • Default node home: ~/.snrd
  • Minimum gas prices: 0stake

Usage

Node Operations

Initialize a New Node

# Initialize node configuration
snrd init <moniker> --chain-id <chain-id>

# Example for testnet
snrd init my-node --chain-id sonr-testnet-1

Start the Node

# Start the blockchain node
snrd start

# Start with custom configuration
snrd start --home ~/.sonr --p2p.laddr tcp://0.0.0.0:26656

Node Management

# Check node status
snrd status

# View node information
snrd query block

# Export application state
snrd export

# Reset node data
snrd reset

Identity Management

Authentication Commands

# Register a new WebAuthn credential
snrd auth register --username <username>

# Login with existing credentials
snrd auth login

The authentication system uses WebAuthn for passwordless, cryptographically secure user authentication. The registration process opens a browser window for biometric or security key authentication.

Wallet Operations

Transaction Management

# Sign a transaction
snrd wallet sign <tx-file>

# Verify a signature
snrd wallet verify <signature> <message>

# Simulate transaction execution
snrd wallet simulate <tx-file>

# Broadcast a signed transaction
snrd wallet broadcast <signed-tx-file>

IPFS Integration

IPFS Node Management

# Start IPFS containers
snrd ipfs start

# View IPFS logs with interactive interface
snrd ipfs logs

# Stop IPFS containers
snrd ipfs stop

The IPFS integration provides decentralized storage capabilities for large data objects referenced by blockchain transactions.

Querying the Network

Basic Queries

# Query account information
snrd query auth account <address>

# Query account balance
snrd query bank balances <address>

# Query validator information
snrd query staking validator <validator-address>

# Query transaction by hash
snrd query tx <hash>

Module-Specific Queries

# Query DID documents
snrd query did did-document <did>

# Query WebAuthn credentials
snrd query did webauthn-credentials <address>

# Query service records
snrd query svc service <service-id>

# Query UCAN capabilities
snrd query ucan capability <capability-id>

Transaction Commands

Standard Transactions

# Send tokens
snrd tx bank send <from-address> <to-address> <amount>

# Delegate to validator
snrd tx staking delegate <validator-address> <amount>

# Submit governance proposal
snrd tx gov submit-proposal <proposal-file>

Custom Module Transactions

# Register a DID document
snrd tx did register-did <did-document-file>

# Register WebAuthn credential
snrd tx did register-webauthn-credential <credential-file>

# Create service record
snrd tx svc create-service <service-config>

# Issue UCAN capability
snrd tx ucan issue-capability <capability-config>

Configuration

Node Configuration

Node configuration is stored in ~/.snrd/config/:

  • config.toml: Node and P2P configuration
  • app.toml: Application-specific settings
  • client.toml: Client configuration
  • genesis.json: Genesis state

Key Configuration Options

# config.toml
[p2p]
laddr = "tcp://0.0.0.0:26656"
persistent_peers = ""
max_num_inbound_peers = 40
max_num_outbound_peers = 10

[consensus]
timeout_commit = "5s"
timeout_propose = "3s"

# app.toml
[api]
enable = true
swagger = true
address = "tcp://0.0.0.0:1317"

[grpc]
enable = true
address = "0.0.0.0:9090"

[json-rpc]
enable = true
address = "0.0.0.0:8545"

Environment Variables

# Override default home directory
export SNRD_HOME=/path/to/custom/home

# Set custom chain ID
export SNRD_CHAIN_ID=custom-chain-1

# Configure logging level
export SNRD_LOG_LEVEL=info

Development

Building

# Build binary
make build

# Build with race detection
make build-race

# Cross-compile for different platforms
GOOS=linux GOARCH=amd64 make build

Testing

# Run unit tests
make test

# Run tests with coverage
make test-cover

# Run integration tests
make test-integration

Code Generation

# Generate protobuf code
make proto-gen

# Generate swagger documentation
make swagger-gen

# Format code
make format

# Run linter
make lint

Troubleshooting

Common Issues

Node Won't Start

# Check configuration
snrd validate-genesis

# Reset corrupted data
snrd unsafe-reset-all

# Check logs
snrd start --log_level debug

Connection Issues

# Test network connectivity
snrd status

# Check peer connections
snrd query tendermint-validator-set

IPFS Issues

# Check Docker status
docker ps

# Reset IPFS containers
snrd ipfs stop
docker system prune
snrd ipfs start

Debugging Commands

# Enable debug logging
snrd start --log_level debug --log_format json

# Profile performance
snrd start --cpu-profile cpu.prof

# Memory profiling
snrd start --mem-profile mem.prof

Network Endpoints

Testnet

  • RPC: https://testnet-rpc.sonr.network
  • REST: https://testnet-api.sonr.network
  • gRPC: testnet-grpc.sonr.network:443
  • Chain ID: sonr-testnet-1

Mainnet

  • RPC: https://rpc.sonr.network
  • REST: https://api.sonr.network
  • gRPC: grpc.sonr.network:443
  • Chain ID: sonr-mainnet-1

API Documentation

  • REST API: Available at /swagger/ endpoint when API server is running
  • gRPC: Protocol buffer definitions in /proto directory
  • GraphQL: Available at /graphql endpoint (if enabled)

Security Considerations

Key Management

  • Private keys are stored in the OS keyring by default
  • Hardware wallet support available via Ledger integration
  • WebAuthn provides passwordless authentication with biometric security

Network Security

  • TLS encryption for all API endpoints
  • P2P encryption via Tendermint
  • Signature verification for all transactions

Best Practices

  • Regular backups of validator keys and node data
  • Use hardware security modules (HSMs) for validator keys
  • Enable firewall rules for production deployments
  • Monitor node health and connectivity

Support

License

Licensed under the Apache License 2.0. See LICENSE for details.