@saw-protocol/sdk
v1.0.8
Published
The unified orchestration SDK for the SAWP Protocol
Downloads
1,022
Readme
Solana Agentic Wallet Protocol (SAWP)
The standard for autonomous AI wallet orchestration on Solana.
🌐 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:
👉 Try the SAWP Agent Chat App
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-openaiBasic 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
- Reasoning: The AI model (Prompt) generates a natural language plan and selects a Tool.
- Intent: The SDK wraps this into a
TransactionIntentcontaining the requested action, parameters, and the AI's internal reasoning. - Policy Check: Before hitting the blockchain, the Policy Plane evaluates the intent against active
PolicyRules(e.g., "Max $50 per swap"). - Sandbox Execution: The intent is passed to the Execution Plane. The logic runs inside the NodeSandbox to prevent CPU spikes or infinite loops.
- Signing & Broadcast: If all checks pass, the Wallet (holding the keys) signs the transaction and broadcasts it to Solana.
- Receipt: An immutable
ExecutionReceiptis 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:
📚 SDK Documentation
Complete API reference, implementation flows, and best practices for the SAWP SDK suite.
📜 Protocol Specification Index
Technical deep-dives into the 7-plane architectural model:
- Architecture & Vision: The cross-plane design philosophy.
- Protocol Entities: Detailed technical breakdown of Intents and Receipts.
- Interface Contracts: Standardized TypeScript definitions.
- Security & Sandboxing: Execution boundary management.
- Multi-Agent Access: Wallet delegation patterns.
- On-Chain Anchoring: Immutable state recording on Solana.
- Agent Skills: Standardizing capability descriptions for LLMs.
📦 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:
Clone & Install:
git clone https://github.com/timileyindev/sawp.git npm installConfigure Environment:
cp .env.example .env # Add your OPENAI_API_KEY and optional VITE_RPC_URLRun the Suite:
npm run test:harness # Interactive CLI for testing all planes npm run dev # Start the local Agent Chat App
