feat: Add Spraay batch payment tools example#1997
feat: Add Spraay batch payment tools example#1997plagtech wants to merge 1 commit intohuggingface:mainfrom
Conversation
Update — March 2026Spraay x402 Gateway has expanded significantly since this PR was opened: 62 paid endpoints across 8 categories (up from 6):
63-tool MCP server on Smithery: @plagtech/spraay-x402-mcp All endpoints are x402-native — agents pay USDC per request on Base. No API keys, no accounts. |
|
Batch payments are a great use case — especially for agents that need to distribute rewards or settle multiple micro-transactions from a single workflow. One architectural consideration: the x402 protocol (HTTP 402 Payment Required) is emerging as the standard for agent-to-service payments, with Coinbase, Stripe, and Cloudflare all shipping implementations. It handles the single-call payment flow natively. For batch scenarios like this, you'd want a There's an open PR that implements the core x402 payment primitive for smolagents with built-in spend governance: #2123. The batch settlement pattern you're describing could compose nicely on top of that foundation. Happy to discuss architecture if useful. |
Thanks for the feedback. Looked at #2123 — the SpendingPolicy pattern aligns with what we enforce on the infrastructure side. Spraay's Agent Wallet system handles spend limits on-chain via session keys on Base mainnet, so the policy enforcement happens at the contract level rather than in application code. The batch payment tools in this PR are the execution layer — multi-recipient settlement across ERC-20 tokens and native ETH through a single contract call. These are different layers solving different problems. SpendingPolicy handles agent-side trust guardrails. Spraay handles on-chain batch execution, gas optimization, and multi-token settlement. An agent framework can use either or both depending on the use case. Re: the x402 point — Spraay's gateway is already x402-native. The batch endpoint sits behind x402 payment middleware, so agents pay per-call to access it. That's how the protocol is designed to work. docs.spraay.app | gateway.spraay.app |
Spraay Batch Payment Tools
Adds an example demonstrating how to use the @tool decorator to create blockchain payment tools for smolagents.
What this example shows
Use case
Batch payments for payroll, airdrops, DAO distributions, and grants. Up to 200 recipients per transaction with ~80% gas savings.
Dependencies
smolagents, web3
Contract: 0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC (Base mainnet)