### Clone Sonr Repository and Install Dependencies (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This snippet clones the Sonr repository and installs its dependencies using a provided script. It's the initial step for setting up the local development environment. ```shell git clone https://github.com/onsonr/sonr.git # Clone the repository sh scripts/install.sh # Install dependencies task # Display the available commands ``` -------------------------------- ### CLI Example for Starting WebAuthn Login Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Command-line interface example using the `snrd` tool to start a WebAuthn login process for an existing DID. It shows the command to query for login initiation. ```bash # Start login for existing DID snrd query did login-start did:sonr:email:abc123def456 ``` -------------------------------- ### Start All Sonr Applications with Turborepo (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This command uses Turborepo to simultaneously start all applications within the Sonr monorepo. It's a convenient way to run the entire project during development. ```shell npm run dev # start all the applications ``` -------------------------------- ### Run Sonr Validator Setup with NPX Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/onboarding.mdx This command initiates the Sonr validator setup process using NPX, guiding users through network configuration, hardware verification, key generation, sentry node deployment, monitoring setup, and security hardening. It requires Node.js and npm to be installed. ```bash npx @sonr/validator-setup my-validator --chain=sonr-testnet-1 ``` -------------------------------- ### CLI Example for Starting WebAuthn Registration Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Command-line interface example using the `snrd` tool to start a WebAuthn registration process for a new email-based DID. It shows the command to execute and a sample JSON response containing the challenge, relying party ID, and user details. ```bash # Start registration for new email-based DID snrd query did register-start did:sonr:email:abc123def456 # Response { "challenge": "R3VpZGVkIGRldGVybWluaXN0aWMgY2hhbGxlbmdl...", "relying_party_id": "sonr.io", "user": { "id": "did:sonr:email:abc123def456", "name": "Email User", "displayName": "Email (abc123de...)" } } ``` -------------------------------- ### Sonr Testnet Setup and Initialization Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/README.md A sequence of bash commands to clone the testnet repository, install dependencies (Devbox), create environment configuration, initialize the testnet components, and start the testnet services. ```bash # 1. Clone repository git clone https://github.com/sonr-io/testnet cd testnet # 2. Install devbox (if not already installed) make all # 3. Create environment configuration make setup # Optional: Edit .env to customize # 4. Initialize testnet make init # 5. Start testnet make start # 6. Verify endpoints make test ``` -------------------------------- ### Setup Project Environment Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/README.md Copies the example environment file to a new file and provides a make command for quick setup. This is essential for configuring the project's runtime variables. ```bash cp .env.example .env make setup ``` -------------------------------- ### Setup Sonr Development Environment (Bash) Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/architecture/passkey-web-authentication.mdx These bash commands outline the steps to set up the Sonr project for development. It includes cloning the repository, installing dependencies using `make install`, and running WebAuthn-specific tests. Ensure you have Git and Make installed. ```bash # Clone repository git clone https://github.com/sonr-io/sonr.git # Install dependencies make install # Run WebAuthn tests make test-webauthn ``` -------------------------------- ### Start and Configure Sonr Blockchain Node Source: https://github.com/sonr-io/sonr/blob/master/cmd/snrd/README.md Commands to start the Sonr blockchain node daemon. The basic command starts with default configurations. An example shows how to start with a custom home directory and P2P listening address. ```bash # Start the blockchain node snrd start # Start with custom configuration snrd start --home ~/.sonr --p2p.laddr tcp://0.0.0.0:26656 ``` -------------------------------- ### Installing Sonr Binary (CLI) Source: https://github.com/sonr-io/sonr/blob/master/README.md This set of commands outlines the process for installing the Sonr binary from its GitHub repository. It includes cloning the repository, navigating into the directory, and then using the `make install` command to build and install the `snrd` executable. Finally, it shows how to verify the installation. ```bash # Clone the repository git clone https://github.com/sonr-io/sonr cd sonr # Install the binary make install # Verify installation snrd version ``` -------------------------------- ### Install Monorepo Dependencies with npm (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This command installs all project dependencies for the Sonr monorepo from the root directory using npm. This is required before running any applications. ```shell npm install # install dependencies ``` -------------------------------- ### Setup Local Sonr Test Network (Bash) Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/vrf-migration.mdx Initializes and runs a local Sonr test network using a Makefile target. Facilitates pre-migration testing. ```bash # Setup test network CHAIN_ID="test-migration" make localnet ``` -------------------------------- ### Local DEX Development Setup Source: https://github.com/sonr-io/sonr/blob/master/x/dex/README.md Commands for setting up a local development environment for the DEX module. This includes starting a local network with ICA enabled, deploying test DEX contracts, and running end-to-end tests. ```bash # Start local chain with ICA enabled make localnet-dex # Deploy test DEX contracts make deploy-test-dex # Run E2E test suite make e2e-test-dex ``` -------------------------------- ### Build and Install snrd Binary Source: https://github.com/sonr-io/sonr/blob/master/cmd/snrd/README.md Instructions to clone the Sonr repository, navigate into the directory, and install the snrd binary using the make command. This is a prerequisite for running the daemon and its associated commands. It assumes Go 1.24+ and Git are installed. ```bash # Clone the repository git clone https://github.com/sonr-io/sonr.git cd sonr # Install the binary make install # Verify installation snrd version ``` -------------------------------- ### Start Sonr Daemon (Bash) Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/vrf-migration.mdx Starts the Sonr node daemon using systemd, typically after an upgrade or maintenance. ```bash systemctl start snrd ``` -------------------------------- ### Configure New Sonr Docs Locally (File Content) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This specifies the content for the `.env.local` file required within the `apps/docs` directory to enable the new Sonr documentation site during local development. ```plaintext NEXT_PUBLIC_NEW_DOCS=true ``` -------------------------------- ### Check Wallet Status CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to check the initialization status and balance information for a given wallet address. ```bash # Check wallet status and balances for an address snrd query dwn wallet-status "idx1abcd..." ``` -------------------------------- ### Sonr Testnet Management Commands Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/README.md A list of Makefile targets for managing the Sonr testnet. These commands cover installation, setup, initialization, starting, stopping, restarting, cleaning, status checks, log viewing, testing, and help. ```bash make all # Check/install devbox make setup # Create .env from template make init # Initialize validators and sentries make start # Start testnet make stop # Stop testnet make restart # Restart testnet make clean # Clean all data (WARNING: destructive) make status # Show status and endpoints make logs # View logs make test # Run basic tests make help # Show available commands ``` -------------------------------- ### Install Devbox using Makefile or Curl Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/README.md Instructions for installing Devbox, which provides the 'snrd' binary. It can be installed automatically via a Makefile or manually using a curl command. ```bash # Auto-install via Makefile make all # Or install manually curl -fsSL https://get.jetpack.io/devbox | bash ``` -------------------------------- ### Configure Protocol CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to configure a new protocol in the DWN. It includes the recipient DID, protocol URI, protocol definition, JSON descriptor, published status, and the signing account. ```bash # Configure a new protocol snrd tx dwn protocols-configure did:example:123 example.com/social/v1 \ '{"types":{"post":{"schema":"https://example.com/schemas/post.json"}}}' \ '{"interface_name":"Protocols","method":"Configure"}' \ --published \ --from alice ``` -------------------------------- ### Clone Sonr Repository Fork (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This command clones your forked version of the Sonr repository from GitHub. This is a necessary step for contributing code. ```shell git clone https://github.com//supabase.git ``` -------------------------------- ### Copy Example .env File Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/ENVIRONMENT.md This command copies the example environment file to a new file named .env, which is used for custom configuration. It's a common practice to start with an example file and then modify it. ```bash cp .env.example .env ``` -------------------------------- ### Install Devbox using Curl Source: https://github.com/sonr-io/sonr/blob/master/chains/README.md Installs the Devbox command-line tool by downloading and executing a script from the official Jetify website. This is a prerequisite for setting up Sonr networks. ```bash curl -fsSL https://get.jetify.com/devbox | bash ``` -------------------------------- ### Shell: snrd query distribution examples Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/commands/snrd_query_distribution.mdx Provides an example of how to perform a basic query on the distribution module using the snrd command-line interface. ```shell snrd query distribution ``` -------------------------------- ### Verify Signature CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to verify a cryptographic signature against a public key and message. ```bash # Verify a signature against a public key snrd query dwn verify-signature "public-key-hex" "message-hex" "signature-hex" ``` -------------------------------- ### Go WebAuthn Authentication Flow Example Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/architecture/passkey-web-authentication.mdx Provides an example of client-side Go code for initiating and completing the WebAuthn authentication flow. It requires setting up AuthenticationOptions, providing an AuthenticatorAssertionResponse, and the credentialID. Errors are handled for any authentication failures. ```go func authenticateWebAuthn(credentialID string) error { client := auth.NewWebAuthnClient() ctx := context.Background() // Begin authentication authOpts := &auth.AuthenticationOptions{ UserVerification: "required", AllowedCredentials: []*auth.CredentialDescriptor{ { Type: "public-key", ID: []byte(credentialID), }, }, } challenge, err := client.BeginAuthentication(ctx, authOpts) if err != nil { return err } // Complete authentication response := &auth.AuthenticatorAssertionResponse{ ClientDataJSON: clientDataJSON, AuthenticatorData: authenticatorData, Signature: signature, UserHandle: userHandle, } result, err := client.CompleteAuthentication(ctx, challenge, response, credentialID) return err } ``` -------------------------------- ### Create Vault CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to create a new vault using enclave-based key generation. It requires the vault name, key ID, and the signing account. ```bash # Create a vault with enclave-based key generation snrd tx dwn create-vault my-vault key-1 --from alice ``` -------------------------------- ### Setting Up Local Development Network (CLI) Source: https://github.com/sonr-io/sonr/blob/master/README.md These commands facilitate the setup of a local development network for Sonr. The `make localnet` command attempts to auto-detect the best method for the user's system, while `make dockernet` specifically uses Docker for a detached network. An optional script is provided for one-time system setup and configuration. ```bash # Standard localnet (auto-detects best method for your system) make localnet # Works on Arch Linux, Ubuntu, macOS, etc. # Docker-based localnet (requires Docker) make dockernet # Runs in detached mode # One-time setup for your system (optional) ./scripts/setup_localnet.sh # Installs dependencies and configures environment ``` -------------------------------- ### Query Protocols CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to query protocols from the DWN, filtering by recipient DID and published status. ```bash # Query protocols snrd query dwn protocols did:example:123 --published-only ``` -------------------------------- ### Query Permissions CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to query permissions in the DWN, filtering by grantor DID and grantee DID. ```bash # Query permissions snrd query dwn permissions did:example:123 --grantee did:example:456 ``` -------------------------------- ### Query Records CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to query records from the DWN, filtering by recipient DID and protocol. ```bash # Query records snrd query dwn records did:example:123 --protocol example.com/profile/v1 ``` -------------------------------- ### Grant Permissions CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to grant permissions in the DWN. It specifies the grantor DID, grantee DID, and the JSON descriptor for the permission grant, along with the signing account. ```bash # Grant permissions snrd tx dwn permissions-grant did:example:123 did:example:456 \ '{"interface_name":"Permissions","method":"Grant"}' \ --from alice ``` -------------------------------- ### Validator Node Configuration Example Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/DOCKER.md Example configuration for a validator node, including its data directory structure and key files. This highlights the critical `priv_validator_key.json` which should be kept secure. ```text ./val-alice/ ├── config/ │ ├── genesis.json # Genesis state │ ├── config.toml # Tendermint config │ ├── app.toml # Application config │ └── priv_validator_key.json # Validator signing key (CRITICAL!) └── data/ # Blockchain data ``` -------------------------------- ### Start Sonr Testnet using Make Source: https://github.com/sonr-io/sonr/blob/master/chains/README.md Deploys the Sonr testnet, which is a multi-node network with production features. This command is used for public testing and staging. ```bash make start NETWORK=testnet ``` -------------------------------- ### Query Vault CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to query the state of a specific vault by its name. ```bash # Query specific vault state snrd query dwn vault my-vault ``` -------------------------------- ### CLI Example: Register New Identity Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/commands/snrd_auth.mdx Provides an example of how to register a new user identity using the 'snrd auth register' command with a specified username. ```shell snrd auth register --username alice ``` -------------------------------- ### Write Record CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to write a new record to the DWN. It specifies the recipient DID, JSON descriptor, record data, protocol, published status, and the signing account. ```bash # Write a new record snrd tx dwn records-write did:example:123 '{"interface_name":"Records","method":"Write"}' '{"name":"Alice","age":30}' \ --protocol example.com/profile/v1 \ --published \ --from alice ``` -------------------------------- ### JavaScript: WebAuthn Registration Flow Example Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md This JavaScript code illustrates the complete WebAuthn registration flow. It begins by calling the 'register-start' endpoint to obtain a challenge and relying party ID. Subsequently, it uses the WebAuthn API ('navigator.credentials.create') in the browser to generate a public key credential. Finally, the generated credential is submitted for verification, typically handled by a CLI or application. This example demonstrates the client-side interaction required for secure user registration. ```javascript // 1. Call RegisterStart endpoint const registerStartResp = await fetch('/sonr/did/v1/register-start', { method: 'POST', body: JSON.stringify({ assertion_did: 'did:sonr:email:abc123def456' }) }); const { challenge, relying_party_id, user } = await registerStartResp.json(); // 2. Perform WebAuthn registration in browser const credential = await navigator.credentials.create({ publicKey: { challenge: base64urlDecode(challenge), rp: { name: "Sonr", id: relying_party_id }, user: { id: new TextEncoder().encode(user.id), name: user.name, displayName: user.displayName }, pubKeyCredParams: [ { alg: -7, type: "public-key" }, // ES256 { alg: -257, type: "public-key" } // RS256 ], authenticatorSelection: { authenticatorAttachment: "platform", requireResidentKey: false, userVerification: "required" }, timeout: 60000, attestation: "none" } }); // 3. Submit credential via MsgRegisterWebAuthnCredential // (Handled by CLI or application) ``` -------------------------------- ### Example Usage for Creating Origin Tokens in Go Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/concepts/motr.mdx Provides a practical example of how to instantiate and populate the NewOriginTokenRequest struct in Go for generating an origin UCAN token. Demonstrates setting audience, attenuations, facts, and validity periods. ```go request := NewOriginTokenRequest{ AudienceDID: "did:example:target-did", Attenuations: []{ {"capability": "read", "resource": "/data"} }, Facts: ["authenticated_user"], NotBefore: time.Now().Unix(), ExpiresAt: time.Now().Add(24 * time.Hour).Unix() } ``` -------------------------------- ### Derive Wallet Addresses CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to derive multi-chain wallet addresses (Cosmos and EVM) from a Decentralized Identifier (DID) and a salt, using BIP44 HD wallet standards. ```bash # Derive multi-chain addresses from DID and salt snrd query dwn wallet-derivation "did:example:alice" "my-salt-123" ``` -------------------------------- ### Install npm Package into a Specific Workspace (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This command demonstrates how to install an npm package into a specific workspace (application or package) within the Sonr monorepo using the `-w` flag. For example, installing 'react' into the 'common' workspace. ```shell npm install react -w common ``` -------------------------------- ### Example: Sonr Cross-Module Transaction for User Onboarding Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/broadcast-transactions.mdx This TypeScript example demonstrates a complete user onboarding process within Sonr, involving multiple modules. It shows how to create a decentralized identity (DID), claim a gasless vault, register a service, and request a root capability using UCAN. ```typescript const tx = { messages: [ // DID Module: Create decentralized identity { type: "did/MsgCreateDID", creator: "sonr1abc...", document: didDocument, webauthnCredential: credential, }, // DWN Module: Claim gasless vault { type: "dwn/MsgClaimVault", creator: "did:sonr:alice123", vaultConfig: vaultCID, mpcThreshold: 3, }, // Service Module: Register domain service { type: "svc/MsgRegisterService", creator: "did:sonr:alice123", domain: "alice-app.com", capabilities: ["dwn:read", "dwn:write"], stakeAmount: "5000usnr", }, // UCAN Module: Request root capability { type: "ucan/MsgIssueRootCapability", issuer: "did:sonr:alice123", audience: "alice-app.com", capabilities: ["service:register"], }, ], fee: { amount: [{ denom: "usnr", amount: "5000" }], // Only service registration fee gasLimit: "500000", }, memo: "Complete onboarding: Identity + Vault + Service + Capabilities", }; ``` -------------------------------- ### Example DNS Configuration for Verification Source: https://github.com/sonr-io/sonr/blob/master/x/svc/README.md Provides an example of how to configure a DNS TXT record for domain verification on Sonr. This includes the record type, name, value (containing the verification token), and TTL. ```plaintext # For domain: app.example.com # Add TXT record: Type: TXT Name: @ (or app if subdomain) Value: sonr-verification=1234567890abcdef TTL: 300 (5 minutes) ``` -------------------------------- ### Run a Specific Sonr Application with Turborepo (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start This command allows you to run a single application within the Sonr monorepo by specifying its scope name. For example, `npm run dev:www` starts the main website. ```shell npm run dev:www ``` -------------------------------- ### Sign with Vault CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to sign a message using a vault's secure enclave. It requires the vault name, the message to sign (as hex), and the signing account. ```bash # Sign a message with vault's secure enclave snrd tx dwn sign-with-vault my-vault "48656c6c6f20576f726c64" --from alice ``` -------------------------------- ### CLI Example: Registering a DID with WebAuthn Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/modules/did.mdx This example demonstrates how to register a new Decentralized Identifier (DID) using the Sonr command-line interface (CLI). It showcases gasless registration, allowing users to create their first identity without requiring cryptocurrency, and offers an option for automatic vault creation. ```bash # Create DID with WebAuthn credential (no tokens required) snrd auth register --username alice # Register with automatic vault creation snrd auth register --username bob --auto-vault ``` -------------------------------- ### Clean and Initialize Project Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/README.md Commands to clean the project environment by removing all data and then reinitializing it. This is useful for starting fresh or after encountering issues. ```bash make clean make init ``` -------------------------------- ### Basic Environment Setup Script Source: https://github.com/sonr-io/sonr/blob/master/scripts/lib/README.md Initializes the Sonr environment by sourcing necessary libraries, ensuring the chain directory exists, and configuring node settings like RPC and REST ports. It utilizes functions from `env.sh` and `config.sh`. ```bash #!/bin/bash SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${SCRIPT_DIR}/lib/env.sh" source "${SCRIPT_DIR}/lib/config.sh" init_env ensure_chain_dir configure_node "$CHAIN_DIR" --rpc-port 26657 --rest-port 1317 ``` -------------------------------- ### Go WebAuthn Registration Flow Example Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/architecture/passkey-web-authentication.mdx Demonstrates the client-side Go code for initiating and completing the WebAuthn registration process. It requires setting up RegistrationOptions and providing AuthenticatorAttestationResponse. Errors are returned for any failures during the flow. ```go func registerWebAuthn() error { client := auth.NewWebAuthnClient() ctx := context.Background() // Begin registration regOpts := &auth.RegistrationOptions{ UserID: "user123", Username: "alice@example.com", DisplayName: "Alice Smith", UserVerification: "preferred", } challenge, err := client.BeginRegistration(ctx, regOpts) if err != nil { return err } // Complete registration response := &auth.AuthenticatorAttestationResponse{ ClientDataJSON: clientDataJSON, AttestationObject: attestationObject, } credential, err := client.CompleteRegistration(ctx, challenge, response) return err } ``` -------------------------------- ### Actor Initialization Error Example Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/concepts/hway.mdx An example error message indicating that an enclave actor failed to start. This often relates to prerequisites for plugin loading, insufficient system resources, or problems with the Proto.Actor system configuration. ```text Enclave actor failed to start ``` -------------------------------- ### POST /sonr/did/v1/register-start Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Initiates the WebAuthn registration process by generating a challenge and providing relying party information. ```APIDOC ## POST /sonr/did/v1/register-start ### Description Initiates the WebAuthn registration process. This endpoint generates a unique challenge and provides the necessary information for the client to start the WebAuthn registration flow. ### Method POST ### Endpoint /sonr/did/v1/register-start ### Parameters #### Request Body - **assertion_did** (string) - Required - The DID (Decentralized Identifier) of the assertion. This is used to link the registration to a specific user or entity. ### Request Example ```json { "assertion_did": "did:sonr:email:abc123def456" } ``` ### Response #### Success Response (200) - **challenge** (string) - A base64url encoded challenge generated deterministically for the authentication. - **relying_party_id** (string) - The ID of the relying party (e.g., "sonr.io"). - **user** (object) - User information for WebAuthn registration. - **id** (string) - The unique user ID. - **name** (string) - The username. - **displayName** (string) - The display name for the user. #### Response Example ```json { "credential_ids": [ "credential_id_1", "credential_id_2" ], "challenge": "QXV0aGVudGljYXRpb24gY2hhbGxlbmdlIGhlcmU...", "relying_party_id": "sonr.io" } ``` ``` -------------------------------- ### GET /dwn/v1/records/{target}/{recordId} Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/queries/query-dwn-single-record.mdx Retrieve a single record by its unique identifier. This endpoint allows for efficient access to known records. ```APIDOC ## GET /dwn/v1/records/{target}/{recordId} ### Description Retrieve a single record by its unique identifier. This endpoint allows for efficient access to known records. ### Method GET ### Endpoint /dwn/v1/records/{target}/{recordId} ### Parameters #### Path Parameters - **target** (string) - Required - The DID of the target account. - **recordId** (string) - Required - The unique identifier of the record to retrieve. ### Request Example ```json { "target": "did:sonr:alice", "recordId": "record_public_123" } ``` ### Response #### Success Response (200) - **recordId** (string) - The unique identifier of the record. - **data** (string) - The actual payload, base64 encoded. - **descriptor** (object) - DWN message metadata. - **authorization** (object) - Access proof. - **protocol** (string) - Conforming protocol URI. - **schema** (string) - Data validation schema. - **parentId** (string) - Hierarchical relationship. - **published** (boolean) - Visibility status. - **isEncrypted** (boolean) - Encryption status. - **encryptionMetadata** (object) - Consensus encryption info. - **keyVersion** (string) - Key rotation tracking. #### Response Example ```json { "recordId": "record_public_123", "data": "aGVsbG8gd29ybGQ=", "descriptor": { "method": "GET" }, "authorization": {}, "protocol": "some_protocol", "schema": "some_schema", "parentId": null, "published": true, "isEncrypted": false } ``` ``` -------------------------------- ### Start Sonr Devnet using Make Source: https://github.com/sonr-io/sonr/blob/master/chains/README.md Initiates the default single-node Sonr development network (devnet) using the Makefile. This command sets up the local development environment. ```bash # Start devnet (default) make start # Or explicitly make start NETWORK=devnet ``` -------------------------------- ### POST /sonr/did/v1/login-start Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Initiates the WebAuthn authentication process by generating a challenge and providing relying party information. ```APIDOC ## POST /sonr/did/v1/login-start ### Description Initiates the WebAuthn authentication process. This endpoint generates a unique challenge and provides the necessary information for the client to perform WebAuthn authentication. ### Method POST ### Endpoint /sonr/did/v1/login-start ### Parameters #### Request Body - **assertion_did** (string) - Required - The DID (Decentralized Identifier) of the assertion. This is used to link the authentication to a specific user or entity. ### Request Example ```json { "assertion_did": "did:sonr:email:abc123def456" } ``` ### Response #### Success Response (200) - **credential_ids** (array) - An array of credential IDs that can be used for authentication. - **credential_id** (string) - A base64url encoded credential ID. - **challenge** (string) - A base64url encoded challenge generated deterministically for the authentication. - **relying_party_id** (string) - The ID of the relying party (e.g., "sonr.io"). #### Response Example ```json { "credential_ids": [ "credential_id_1", "credential_id_2" ], "challenge": "QXV0aGVudGljYXRpb24gY2hhbGxlbmdlIGhlcmU...", "relying_party_id": "sonr.io" } ``` ``` -------------------------------- ### Set Environment Variables for Sonr Blockchain (Shell) Source: https://github.com/sonr-io/sonr/wiki/1. Quick-Start These environment variables are required to run the Sonr blockchain locally. They configure connection details, TLS settings, and the operating mode. ```shell CONNECT_SERVER_HOST="localhost" CONNECT_SERVER_PORT="8080" TLS_CERT_FILE="" TLS_KEY_FILE="" ENVIRONMENT="dev" HIGHWAY_MODE="fiber" ``` -------------------------------- ### User Setup Utility in Go Source: https://github.com/sonr-io/sonr/blob/master/test/e2e/README.md The SetupTestUsers utility function in Go is used to set up and fund test users for E2E testing. It takes a testing object, configuration, and funding amount to create and fund new user accounts. ```go // Setup and fund test users fundAmount := math.NewInt(10_000_000) users := utils.SetupTestUsers(t, cfg, fundAmount) ``` -------------------------------- ### Override Docker Image at Runtime (Bash) Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/ENVIRONMENT.md Example of how to override the default Docker image used by the Sonr project at runtime. This is achieved by setting the DOCKER_IMAGE environment variable before running the 'make start' command. ```bash export DOCKER_IMAGE=onsonr/snrd:v1.2.3 make start ``` -------------------------------- ### Troubleshoot Container Startup Issues Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/DOCKER.md Provides common troubleshooting steps for containers that fail to start. This includes checking logs, resource usage, network existence, and options for recreating the container. ```bash # Check logs docker compose logs # Check resource usage docker stats # Verify networks exist docker network ls | grep -E "net-|cloudflare" # Recreate container docker compose up -d --force-recreate ``` -------------------------------- ### Get Sonr Chain ID from Genesis (Bash) Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/vrf-migration.mdx Extracts the chain ID from the Sonr node's genesis configuration file. Useful for ensuring the correct chain ID is used when generating VRF keys. ```bash # Check chain-id in genesis jq '.chain_id' ~/.sonr/config/genesis.json ``` -------------------------------- ### Configure Encryption Setting in Genesis (JSON) Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/vrf-migration.mdx Sets the 'encryption_enabled' parameter to false within the 'dwn' section of the application state in a network's genesis configuration file. This is applicable for new networks to start without encryption enabled. ```json { "app_state": { "dwn": { "params": { "encryption_enabled": false } } } } ``` -------------------------------- ### Build Sonr Blockchain Binary Source: https://context7.com/sonr-io/sonr/llms.txt Commands for building the Sonr blockchain binary and installing it to the GOPATH/bin directory, essential for development and local testing environments. ```bash # Build blockchain binary make build # Output: build/snrd # Install to $GOPATH/bin make install ``` -------------------------------- ### Build and Install Highway Service Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/concepts/hway.mdx Commands to build and install the Highway service using Make or direct Go build commands. Ensure Go 1.24.4 or later is installed. ```bash # Build and install the Highway service make install # Or build directly cd cmd/hway go build -o hway . ``` -------------------------------- ### JavaScript: WebAuthn Authentication Flow Example Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md This JavaScript code provides a complete WebAuthn authentication flow. It starts by invoking the 'login-start' endpoint to retrieve credential IDs and a challenge. Then, it utilizes the WebAuthn API ('navigator.credentials.get') in the browser to obtain an assertion from the user's authenticator. The obtained assertion is then submitted for verification. This client-side script facilitates the process of securely authenticating users via WebAuthn. ```javascript // 1. Call LoginStart endpoint const loginStartResp = await fetch('/sonr/did/v1/login-start', { method: 'POST', body: JSON.stringify({ assertion_did: 'did:sonr:email:abc123def456' }) }); const { credential_ids, challenge, relying_party_id } = await loginStartResp.json(); // 2. Perform WebAuthn authentication in browser const assertion = await navigator.credentials.get({ publicKey: { challenge: base64urlDecode(challenge), rpId: relying_party_id, allowCredentials: credential_ids.map(id => ({ type: "public-key", id: base64urlDecode(id) })), userVerification: "required", timeout: 60000 } }); // 3. Submit assertion for verification // (Handled by CLI or application) ``` -------------------------------- ### Initiate and Verify Domain for Service Source: https://github.com/sonr-io/sonr/blob/master/x/svc/README.md This snippet outlines the bash commands to initiate, verify, and complete the domain verification process for registering a service on Sonr. It requires manual addition of a TXT record to your DNS provider. ```bash # Step 1: Initiate verification snrd tx svc initiate-domain-verification your-domain.com --from your-key # Step 2: Add TXT record to DNS # Record: sonr-verification= # Step 3: Wait for DNS propagation (usually 5-30 minutes) # Step 4: Complete verification snrd tx svc verify-domain your-domain.com --from your-key ``` -------------------------------- ### Get Credentials By DID Source: https://github.com/sonr-io/sonr/blob/master/proto/did/v1/did_query_docs.md Gets all credentials (verifiable and WebAuthn) associated with a specific DID, showing vault storage status if applicable. ```APIDOC ## GET /did/{did}/credentials ### Description Gets all credentials, both verifiable and WebAuthn, associated with a DID, indicating vault storage status. ### Method GET ### Endpoint /did/{did}/credentials ### Parameters #### Path Parameters - **did** (string) - Required - The Decentralized Identifier (DID) to retrieve credentials for. ### Query Details - Gets all credentials associated with a DID - Includes both verifiable and WebAuthn credentials - Shows vault storage status if applicable ### Usage Example ```bash snrd query did credentials-by-did did:sonr:123abc ``` ``` -------------------------------- ### Get Service Endpoint Source: https://github.com/sonr-io/sonr/blob/master/proto/did/v1/did_query_docs.md Gets specific service endpoint information, including service type, endpoint URLs, and service metadata. ```APIDOC ## GET /did/{did}/service/{serviceId} ### Description Gets specific service endpoint information, returning service type, endpoint URLs, and service metadata. ### Method GET ### Endpoint /did/{did}/service/{serviceId} ### Parameters #### Path Parameters - **did** (string) - Required - The Decentralized Identifier (DID) the service belongs to. - **serviceId** (string) - Required - The ID of the service endpoint to retrieve. ### Query Details - Gets specific service endpoint information - Returns service type and endpoint URLs - Includes service metadata ### Usage Example ```bash snrd query did service did:sonr:123abc service-1 ``` ``` -------------------------------- ### Running Local Sonr Testnets (CLI) Source: https://github.com/sonr-io/sonr/blob/master/README.md This snippet provides commands for managing local Sonr test networks. It includes instructions for starting a single-node testnet for quick iteration, launching a multi-node testnet using Starship, and stopping the testnet when no longer needed. These are crucial for local development and testing. ```bash # Start single-node testnet (quick iteration) make localnet # Start multi-node testnet with Starship make testnet-start # Stop testnet make testnet-stop ``` -------------------------------- ### CLI Example: Registering a DEX Account Source: https://github.com/sonr-io/sonr/blob/master/x/dex/README.md This bash command registers a new DEX account on the Osmosis network. It requires the DID of the account owner, the IBC connection ID, the desired features (swap, liquidity, orders), and the originating account for the transaction. ```bash snrd tx dex register-account \ --did did:sonr:alice \ --connection connection-0 \ --features swap,liquidity,orders \ --from alice ``` -------------------------------- ### Sonr CLI: Domain Verification and Service Registration Commands Source: https://github.com/sonr-io/sonr/blob/master/proto/svc/v1/svc_docs.md Provides examples of using the Sonr CLI to manage domain verification and service registration. These commands cover initiating verification, verifying ownership, registering services, querying verification status, and listing services associated with a domain. ```bash # Initiate domain verification snrd tx svc initiate-domain-verification example.com # Verify domain ownership snrd tx svc verify-domain example.com # Register service snrd tx svc register-service service-1 example.com --permissions read,write # Query verification status snrd query svc domain example.com # List services for domain snrd query svc services-by-domain example.com ``` -------------------------------- ### Complete DID Workflow Example - Go Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/decentralized-identity.mdx Demonstrates a complete workflow for generating an Ed25519 key pair, creating a DID from the public key, converting the DID to its string representation, and deriving a blockchain address. Includes error handling. ```Go package main import ( "fmt" "github.com/libp2p/go-libp2p/core/crypto" "github.com/sonr-io/crypto/keys" ) func main() { // Generate a new key pair privateKey, publicKey, err := crypto.GenerateKeyPair(crypto.Ed25519, -1) if err != nil { panic(err) } // Create a DID did, err := keys.NewDID(publicKey) if err != nil { panic(err) } // Get the DID string didString := did.String() fmt.Println("Generated DID:", didString) // Derive blockchain address address, err := did.Address() if err != nil { panic(err) } fmt.Println("Blockchain Address:", address) } ``` -------------------------------- ### Basic Gasless WebAuthn Registration (CLI) Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Example CLI commands for performing gasless WebAuthn registration. These commands allow users to create a DID and associated WebAuthn credential without requiring cryptocurrency. ```bash # Create DID with WebAuthn credential (no tokens required) snrd auth register --username alice # Register with automatic vault creation snrd auth register --username bob --auto-vault # Register with specific controller address snrd auth register --username carol --controller cosmos1abc...xyz ``` -------------------------------- ### Install Docker and Docker Compose Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/README.md Commands to check if Docker and Docker Compose are installed on the system. These are essential prerequisites for running the testnet environment. ```bash docker --version docker compose version ``` -------------------------------- ### Start Sonr Containers Source: https://github.com/sonr-io/sonr/blob/master/networks/testnet/DOCKER.md Starts all Sonr containers in detached mode. This can be done using either the 'make' command or 'docker compose'. ```bash make start ``` ```bash docker compose up -d ``` -------------------------------- ### Sonr CLI Commands for Service Module Source: https://github.com/sonr-io/sonr/blob/master/README.md Provides examples of Sonr CLI commands for the Service module, covering domain verification initiation and completion, and service registration with specified permissions. These commands are used for decentralized service discovery and management. ```bash # Verify domain ownership snrd tx svc initiate-domain-verification example.com --from alice snrd tx svc verify-domain example.com --from alice # Register service snrd tx svc register-service my-service example.com \ --permissions "read,write" --from alice ``` -------------------------------- ### Query Vaults CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to query all vaults owned by a specific address. The `--owner-only` flag can be used for filtering. ```bash # Query all vaults owned by an address snrd query dwn vaults sonr1... --owner-only ``` -------------------------------- ### List Consumer Chains Source: https://github.com/sonr-io/sonr/wiki/9. Consumer-Launch Queries the provider chain to list all configured consumer chains using the 'gaiad' CLI. This is useful for obtaining chain IDs and client information required for setting up IBC connections. ```bash gaiad q provider list-consumer-chains ``` -------------------------------- ### Delete Record CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to delete a record from the DWN. It requires the recipient DID, record ID, JSON descriptor, and the signing account. ```bash # Delete a record snrd tx dwn records-delete did:example:123 record-123 '{"interface_name":"Records","method":"Delete"}' \ --from alice ``` -------------------------------- ### Start Sonar Blockchain Node Source: https://github.com/sonr-io/sonr/blob/master/docs/guides/configure-local-node.mdx Starts the Sonar blockchain node with the configured genesis file. This command initiates the node process, allowing it to connect to the network and participate in consensus. ```shell sonrd start ``` -------------------------------- ### QueryRegisterStart Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Initiates a WebAuthn registration ceremony for a new assertion DID. This endpoint generates registration options and a challenge for creating a new WebAuthn credential. ```APIDOC ## POST /did/register-start ### Description Initiates a WebAuthn registration ceremony for a new assertion DID. Generates registration options and challenge for creating a new WebAuthn credential. ### Method POST ### Endpoint /did/register-start ### Parameters #### Request Body - **assertion_did** (string) - Required - The assertion DID for which to start registration. Format: did:sonr:email: or did:sonr:phone: ### Request Example ```json { "assertion_did": "did:sonr:email:abc123def456" } ``` ### Response #### Success Response (200) - **challenge** (bytes) - Base64url-encoded 32-byte challenge. - **relying_party_id** (string) - Relying party identifier (domain). - **user** (object) - User information containing id, name, and displayName. - **id** (string) - User identifier. - **name** (string) - User's name. - **displayName** (string) - User's display name. #### Response Example ```json { "challenge": "R3VpZGVkIGRldGVybWluaXN0aWMgY2hhbGxlbmdl...", "relying_party_id": "sonr.io", "user": { "id": "did:sonr:email:abc123def456", "name": "Email User", "displayName": "Email (abc123de...)" } } ``` ### Error Cases - **ErrInvalidRequest**: Nil request or empty assertion DID. - **ErrAssertionAlreadyExists**: Assertion DID already registered. ``` -------------------------------- ### Broadcast Transaction CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to broadcast a transaction using a vault's enclave. It requires the vault name, the transaction bytes, and the signing account. ```bash # Broadcast a transaction using vault's enclave snrd tx dwn broadcast-tx my-vault "transaction-bytes" --from alice ``` -------------------------------- ### Protobuf Definitions for WebAuthn Login Start Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Protocol Buffer definitions for the `QueryLoginStartRequest` and `QueryLoginStartResponse` messages used in the Sonr DID module to initiate WebAuthn login. The request includes the assertion DID, and the response provides a list of allowed credential IDs, a challenge, and the relying party ID. ```protobuf message QueryLoginStartRequest { string assertion_did = 1; // Existing assertion DID } message QueryLoginStartResponse { repeated string credential_ids = 1; // WebAuthn credential IDs for allowCredentials bytes challenge = 2; // Base64url-encoded 32-byte challenge string relying_party_id = 3; // Relying party identifier } ``` -------------------------------- ### Refresh Vault CLI Example (bash) Source: https://github.com/sonr-io/sonr/blob/master/x/dwn/README.md Example command to refresh the enclave state of a vault. It requires the vault name and the signing account. Note: Requires a minimum interval between refreshes. ```bash # Refresh vault enclave state (requires minimum interval) snrd tx dwn refresh-vault my-vault --from alice ``` -------------------------------- ### Protobuf Definitions for WebAuthn Registration Start Source: https://github.com/sonr-io/sonr/blob/master/x/did/README.md Protocol Buffer definitions for the `QueryRegisterStartRequest` and `QueryRegisterStartResponse` messages used in the Sonr DID module to initiate WebAuthn registration. The request specifies the assertion DID, and the response provides a challenge, relying party ID, and user information. ```protobuf message QueryRegisterStartRequest { string assertion_did = 1; // Format: did:sonr:email: or did:sonr:phone: } message QueryRegisterStartResponse { bytes challenge = 1; // Base64url-encoded 32-byte challenge string relying_party_id = 2; // Relying party identifier (domain) map user = 3; // User info: id, name, displayName } ``` -------------------------------- ### Redis Connection Error Example Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/concepts/hway.mdx An example log message indicating a failure to connect to the Redis server. This typically occurs when the Redis server is not running or not accessible at the configured address and port. ```text could not run server: dial tcp 127.0.0.1:6379: connect: connection refused ``` -------------------------------- ### Building Sonr Binary (Make) Source: https://github.com/sonr-io/sonr/blob/master/cmd/snrd/README.md Commands to build the Sonr binary using Make. Includes options for regular builds, builds with race detection, and cross-compilation for different operating systems and architectures. ```bash # Build binary make build # Build with race detection make build-race # Cross-compile for different platforms GOOS=linux GOARCH=amd64 make build ``` -------------------------------- ### Submit Staking Transaction Example Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/commands/snrd_tx_staking.mdx Example of how to submit a staking transaction using the 'snrd' CLI. This command requires specifying the transaction type and associated flags like 'from' and 'chain-id'. ```shell snrd tx staking --from alice --chain-id sonrtest_1-1 ``` -------------------------------- ### Start a Sonr Blockchain Node Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/commands/snrd.mdx This command starts the Sonr blockchain daemon, running a full node. Ensure all configurations are set correctly before execution. This is a fundamental command for participating in the Sonr network. ```shell snrd start ``` -------------------------------- ### Monorepo Installation and Build Commands Source: https://github.com/sonr-io/sonr/blob/master/README.md These bash commands are used to manage dependencies and build the entire monorepo. They leverage pnpm for efficient package management. ```bash pnpm install pnpm build pnpm dev ``` -------------------------------- ### Initiate and Verify Domain with Sonr CLI Source: https://github.com/sonr-io/sonr/blob/master/docs/reference/modules/svc.mdx This snippet demonstrates the command-line process for verifying domain ownership for service registration. It involves initiating the verification, adding a DNS TXT record, and then completing the verification. ```bash # Initiate domain verification snrd tx svc initiate-domain-verification example.com --from alice # Verify domain after DNS propagation snrd tx svc verify-domain example.com --from alice ```