Skip to content

timileyindev/sawp

Repository files navigation

SAWP Logo

Solana Agentic Wallet Protocol (SAWP)

The standard for autonomous AI wallet orchestration on Solana.

NPM Version NPM Downloads GitHub Stars Live Demo

WATCH the demo video here


🌐 The Vision

SAWP is an open-source protocol and SDK suite designed to empower AI agents with secure, autonomous, and programmable financial capabilities. It defines a unified standard for how agents create identities, subscribe to wallets, sign transactions, and interact with the Solana ecosystemβ€”all while operating within strict, human-defined safety boundaries.

Just as ERC-4337 brought account abstraction to Ethereum, SAWP brings agentic abstraction to Solana, ensuring that security is structural, models are interchangeable, and agents are first-class network citizens.


πŸ’Ž Core Pillars

1. The Wallet is Infrastructure

In SAWP, the wallet is a physical execution daemon (the Execution Plane) that secures keys. The agent is a logical client (the Tooling Plane) that dispatches signed intents. This separation allows you to swap AI models (GPT-4o, Claude 3.5, Local Llama) without migrating your keys or re-writing your logic.

2. Structural Security (The Sandbox)

Every transaction intent generated by an AI is subjected to the SAWP Sandbox.

  • Policy Engine: Enforces spend limits, network scope, and allowed program IDs.
  • NodeSandbox: Wraps execution in an isolated environment with CPU/Memory limiting and timeout protection.
  • Observation Plane: Real-time audit logging of every intent, decision, and signature.

3. Network Citizenship

Agents are not just scripts; they have DIDs (Decentralized Identifiers). They can discover other agents, verify each other's signatures, delegate permissions, and connect to dApps via the same interfaces used by human wallets.


πŸš€ Live Demo

Experience the protocol in action without setting up a local environment:

Features on display:

  • Autonomous Tool Selection: Watch the agent decide which Solana tools to call.
  • Real-time Observability: Inspect the sandbox metrics and policy evaluations for every prompt.
  • On-chain Action: Execute real Devnet transactions (Airdrops, Transfers, Swaps).

πŸ› οΈ Quick Start (v1.0.8)

Installation

Install the primary orchestration SDK:

npm install @saw-protocol/sdk @saw-protocol/keystore-env @saw-protocol/runtime-openai

Basic Implementation

import { SAWP, Agent, generateAgentDID } from "@saw-protocol/sdk";
import { OpenAIRuntime } from "@saw-protocol/runtime-openai";

// 1. Initialize the Execution Plane (Wallet)
const wallet = await SAWP.Wallet.create({
  keyStore: new MyCustomKeyStore(),
  network: "devnet",
});

// 2. Provision Identity & Authorize
const { did, keypair } = generateAgentDID();
await wallet.authorize({ id: did, did, keypair });

// 3. Synthesize the Agent
const agent = new Agent({
  did,
  runtime: new OpenAIRuntime({ apiKey: "sk-..." }),
  targetWallet: wallet, // Same-process mode
  keypair,
});

// 4. Execute
const receipt = await agent.run(
  "Check my balance and airdrop some SOL if I'm low.",
);
console.log(receipt.outcome); // 'success'

🧠 Behind the Scenes: How it Works

The SAWP protocol operates on a decoupled Intent-Action-Receipt flow. This ensures that the AI never has direct access to private keys, and every decision is verifiable.

1. The Intent Flow

  1. Reasoning: The AI model (Prompt) generates a natural language plan and selects a Tool.
  2. Intent: The SDK wraps this into a TransactionIntent containing the requested action, parameters, and the AI's internal reasoning.
  3. Policy Check: Before hitting the blockchain, the Policy Plane evaluates the intent against active PolicyRules (e.g., "Max $50 per swap").
  4. Sandbox Execution: The intent is passed to the Execution Plane. The logic runs inside the NodeSandbox to prevent CPU spikes or infinite loops.
  5. Signing & Broadcast: If all checks pass, the Wallet (holding the keys) signs the transaction and broadcasts it to Solana.
  6. Receipt: An immutable ExecutionReceipt is generated, hashed, and recorded in the Observation Plane.

2. The 7 Planes of SAWP

To ensure modularity, the protocol is strictly divided into functional planes:

  • πŸ›‘οΈ Identity Plane: Manages Ed25519-based DIDs for Agents and Wallets.
  • πŸ“œ Policy Plane: A stateful engine that evaluates permissions in real-time.
  • ⚑ Execution Plane: The bridge to the Solana blockchain (Building, Signing, Broadcasting).
  • πŸ‘οΈ Observation Plane: The "black box" recorder providing full auditability.
  • πŸ“‘ Communication Plane: A secure messaging layer (WebSocket/Local) between Agents and Wallets.
  • πŸ”— Connection Plane: Standardized interfaces for dApps to "Connect Agent Wallet".
  • πŸ› οΈ Tooling Plane: The catalog of high-level capabilities (DeFi, Staking, NFT) exposed to AI models.

πŸ“‘ Developer Resources & Documentation

For a comprehensive guide to building with SAWP, please refer to our dedicated documentation:

Complete API reference, implementation flows, and best practices for the SAWP SDK suite.

Technical deep-dives into the 7-plane architectural model:


πŸ“¦ Package Ecosystem

SAWP is built as a modular monorepo. Use only what you need.

Package Purpose
@saw-protocol/sdk The unified entry point for all features.
@saw-protocol/core Core interfaces, types, and cryptographic primitives.
@saw-protocol/policy The rule-based permission and spending limit engine.
@saw-protocol/sandbox Process-level execution isolation and timeout management.
@saw-protocol/builder High-level Solana transaction construction.
@saw-protocol/logger Highly configurable logging pipeline for the Observation Plane.
@saw-protocol/widget Premium React components for dApp wallet connections.
@saw-protocol/runtime-* Adapters for OpenAI, Anthropic, and Local models.

🧰 Integrated Tool Catalog

When you initialize a SAWP Agent, it automatically gains access to a robust set of Solana-native capabilities:

  • Self-Awareness: get_my_address, get_my_sol_balance, get_agent_info.
  • Balance & Accounts: get_sol_balance, get_token_balance, get_account_info.
  • Transfers: solana_transfer, spl_transfer.
  • DeFi (Jupiter): get_jupiter_quote, jupiter_swap, get_token_price.
  • Staking: stake_sol, unstake_sol.
  • Network: estimate_gas_fee, request_airdrop, get_network_stats.

πŸ“‚ Project Structure

  • /packages: The core protocol source code.
  • /agent-chat-app: The source code for the Live Demo.
  • /spec: Comprehensive protocol specifications (Identity through to On-Chain Anchoring).
  • /docs: API references and implementation guides.

πŸ’» Local Development

If you want to contribute to the protocol or run the chat app locally:

  1. Clone & Install:

    git clone https://github.com/timileyindev/sawp.git
    npm install
  2. Configure Environment:

    cp .env.example .env
    # Add your OPENAI_API_KEY and optional VITE_RPC_URL
  3. Run the Suite:

    npm run test:harness  # Interactive CLI for testing all planes
    npm run dev           # Start the local Agent Chat App

Built for the future of autonomous finance on Solana.

Empowering agents with integrity.

About

SAWP is an open-source protocol and SDK suite designed to empower AI agents with secure, autonomous, and programmable financial capabilities. It defines a unified standard for how agents create identities, subscribe to wallets, sign transactions, and interact with the Solana ecosystem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors