feat : Implemented Solana Agentic Autopay Suite#135
Open
Terry3nty wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds the Solana Agentic Autopay (SAA) suite to the ZeroClaw plugins repo: a shared Rust core for Solana serialization/RPC helpers plus two tool plugins for building an SPL Token delegation approval transaction (T1) and executing delegated token transfers with a daily spend cap (T2).
Changes:
- Introduces
solana-plugin-corewith Pubkey/PDA+ATA derivation, legacy transaction/message serialization, and JSON-RPC helper utilities. - Adds
autopay-delegatetool plugin to generate an unsigned SPL TokenApprovetransaction. - Adds
autopay-chargetool plugin to sign/submit delegated SPL Token transfers and enforce a daily cap via RPC history scanning.
Reviewed changes
Copilot reviewed 14 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/solana-plugin-core/src/lib.rs | Implements Solana primitives (Pubkey, PDA/ATA, message/tx serialization) and RPC helpers used by the autopay tools. |
| plugins/solana-plugin-core/Cargo.toml | Defines the new shared core crate and its dependencies. |
| plugins/solana-plugin-core/Cargo.lock | Locks dependencies for deterministic builds of the core crate. |
| plugins/autopay-delegate/src/lib.rs | WASM tool-plugin component wrapper and argument parsing for the delegate transaction builder. |
| plugins/autopay-delegate/src/delegate.rs | Builds the unsigned SPL Token Approve transaction and returns it base64-encoded. |
| plugins/autopay-delegate/tests/delegate.rs | Adds a basic host test for building the delegate transaction. |
| plugins/autopay-delegate/README.md | Documents the T1 delegate plugin behavior, usage, and threat model. |
| plugins/autopay-delegate/manifest.toml | Declares plugin metadata/capabilities/permissions for autopay-delegate. |
| plugins/autopay-delegate/Cargo.toml | Defines the autopay-delegate crate configuration and dependencies. |
| plugins/autopay-delegate/Cargo.lock | Locks dependencies for deterministic builds of the delegate plugin. |
| plugins/autopay-charge/src/lib.rs | WASM tool-plugin component wrapper and config parsing for autonomous charges. |
| plugins/autopay-charge/src/charge.rs | Implements the delegated transfer execution flow and daily-cap enforcement. |
| plugins/autopay-charge/tests/charge.rs | Adds host tests for success, insufficient allowance, and daily-cap exceeded cases. |
| plugins/autopay-charge/README.md | Documents the T2 charge plugin behavior, usage, and threat model. |
| plugins/autopay-charge/manifest.toml | Declares plugin metadata/capabilities/permissions for autopay-charge. |
| plugins/autopay-charge/Cargo.toml | Defines the autopay-charge crate configuration and dependencies (incl. wasm-only HTTP). |
| plugins/autopay-charge/Cargo.lock | Locks dependencies for deterministic builds of the charge plugin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+62
to
+74
| pub fn find_program_address(seeds: &[&[u8]], program_id: &Pubkey) -> Option<(Pubkey, u8)> { | ||
| let mut bump = 255u8; | ||
| while bump > 0 { | ||
| let mut seeds_with_bump = seeds.to_vec(); | ||
| let bump_slice = [bump]; | ||
| seeds_with_bump.push(&bump_slice); | ||
| if let Some(addr) = create_program_address(&seeds_with_bump, program_id) { | ||
| return Some((addr, bump)); | ||
| } | ||
| bump -= 1; | ||
| } | ||
| None | ||
| } |
Comment on lines
+323
to
+332
| pub fn sign(&mut self, keypairs: &[ed25519_dalek::SigningKey]) { | ||
| let message_bytes = self.message.serialize(); | ||
| for (i, key) in keypairs.iter().enumerate() { | ||
| if i < self.signatures.len() { | ||
| use ed25519_dalek::Signer; | ||
| let sig = key.sign(&message_bytes); | ||
| self.signatures[i] = sig.to_bytes(); | ||
| } | ||
| } | ||
| } |
Comment on lines
+548
to
+551
| let result = &parsed["result"]; | ||
| if result.is_null() { | ||
| return Ok(0); | ||
| } |
Comment on lines
+53
to
+56
| // 3. Enforce Daily Cap (scan transactions in the last 24 hours) | ||
| let sigs = get_signatures_for_address(requester, rpc_url, &agent_pubkey, 20) | ||
| .map_err(|e| format!("Failed to query transaction history: {e}"))?; | ||
|
|
Comment on lines
+74
to
+78
| // Query transaction details to see how much was spent from user_ata | ||
| let amt = get_transaction_transfer_amount(requester, rpc_url, &sig.signature, &user_ata) | ||
| .unwrap_or(0); // If query fails, fail safe or log (we assume 0 for simplicity or we can fail closed) | ||
|
|
||
| spent_24h += amt; |
| Part of the **Solana Agentic Autopay (SAA)** suite. A T1 (Build) tool plugin that constructs an unsigned transaction for the owner to delegate SPL Token spending power to the agent. | ||
|
|
||
| ## What It Does | ||
| Generates an unsigned transaction in Base58 legacy format that authorizes the agent's public key to spend up to a specific limit of SPL tokens (e.g., USDC) from the user's wallet. The user signs this transaction via their browser wallet or phone interface. The agent never gains access to the user's private key. |
|
|
||
| ## Threat Model & Security Guardrails | ||
| * **Threat 1: Prompt Injection / Compromised LLM** | ||
| * *Attack*: An attacker tricks the agent into transfering all user funds to their account. |
Comment on lines
+6
to
+9
| let owner = Pubkey::from_string("DBD8hAwLDRQkTsu6EqviaYNGKPnsAMmQonxf7AH8ZcFY").unwrap(); | ||
| let delegate = Pubkey::from_string("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU").unwrap(); | ||
| let mint = Pubkey::from_string("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL").unwrap(); | ||
| let amount = 50_000_000u64; // 50 USDC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solana Agentic Autopay (SAA) Protocol Suite
This PR introduces the Solana Agentic Autopay (SAA) protocol suite to ZeroClaw plugins, providing a non-custodial "Direct Debit" payment system for autonomous AI agents on Solana via native SPL Token Delegation.
Included Plugins & Modules
plugins/solana-plugin-core(Shared Substrate - Track E):HttpRequestertrait for clean host testing and sandboxedwakiWASM execution.plugins/autopay-delegate(T1 Tool Plugin):Approvetransaction for the owner to delegate spending allowance to the agent.permissions = []).plugins/autopay-charge(T2 Tool Plugin):Verification & Testing
cargo test) pass cleanly across all crates without live network dependency.autopay-delegateandautopay-chargebuild cleanly targetingwasm32-wasip2in release mode.