LangChain tools for Spraay — multi-chain batch payments and x402 gateway for AI agents
Project description
langchain-spraay
LangChain tools for Spraay — multi-chain batch payments and x402 payment gateway for AI agents.
Overview
langchain-spraay provides LangChain-compatible tools that let AI agents:
- Send batch payments to up to 200 recipients in a single transaction across 13+ chains
- Access 200+ AI models via pay-per-request (no API keys needed)
- Query price oracles, execute DeFi swaps, manage payroll, and more
- Pay with USDC on Base via the x402 payment protocol — no accounts, no API keys
Installation
# Gateway tools (HTTP-based, no web3 needed)
pip install langchain-spraay
# Include on-chain smart contract tools
pip install langchain-spraay[onchain]
Quick Start
Gateway Tools (Recommended)
import os
from langchain_spraay import SpraayGatewayTool, SpraayToolkit
os.environ["SPRAAY_PRIVATE_KEY"] = "your-private-key-with-usdc-on-base"
# Use individual tools
tool = SpraayGatewayTool()
result = tool.invoke({
"endpoint": "/price/eth",
"method": "GET"
})
# Or load all tools via toolkit
toolkit = SpraayToolkit()
tools = toolkit.get_tools() # 4 gateway tools ready to use
Batch Payments
from langchain_spraay import SpraayBatchPaymentTool
tool = SpraayBatchPaymentTool()
result = tool.invoke({
"chain": "base",
"token": "USDC",
"recipients": ["0xAbc...", "0xDef...", "0x123..."],
"amounts": ["100", "250", "50"]
})
AI Inference
from langchain_spraay import SpraayAIInferenceTool
tool = SpraayAIInferenceTool()
result = tool.invoke({
"prompt": "Explain quantum computing in one paragraph",
"model": "gpt-4o-mini",
"provider": "openrouter"
})
On-Chain Tools
from langchain_spraay import SpraayBatchSendETH
tool = SpraayBatchSendETH()
result = tool.invoke({
"recipients": ["0xAbc...", "0xDef..."],
"amount_per_recipient_eth": "0.01"
})
With LangChain Agents
from langchain_spraay import SpraayToolkit
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
llm = ChatOpenAI(model="gpt-4o-mini")
toolkit = SpraayToolkit(include_onchain=True)
tools = toolkit.get_tools()
agent = create_react_agent(llm, tools)
result = agent.invoke({
"messages": [{"role": "user", "content": "Send 0.01 ETH to 0xAbc... and 0xDef..."}]
})
Environment Variables
| Variable | Required | Description |
|---|---|---|
SPRAAY_PRIVATE_KEY |
Yes | Private key of wallet with USDC on Base |
SPRAAY_GATEWAY_URL |
No | Gateway URL (default: https://gateway.spraay.app) |
SPRAAY_RPC_URL |
No | RPC URL for on-chain tools (default: https://mainnet.base.org) |
SPRAAY_CONTRACT_ADDRESS |
No | Spraay V2 contract address (default: mainnet) |
Available Tools
Gateway Tools
| Tool | Description |
|---|---|
SpraayGatewayTool |
Generic access to all 76+ gateway endpoints |
SpraayBatchPaymentTool |
Multi-chain batch payments (13+ chains) |
SpraayAIInferenceTool |
AI inference (200+ models, 3 providers) |
SpraayPriceOracleTool |
Real-time crypto price lookups |
On-Chain Tools (require web3)
| Tool | Description |
|---|---|
SpraayBatchSendETH |
Batch send equal ETH amounts |
SpraayBatchSendToken |
Batch send equal ERC-20 amounts |
SpraayBatchSendETHVariable |
Batch send variable ETH amounts |
SpraayBatchSendTokenVariable |
Batch send variable ERC-20 amounts |
Supported Chains
Base, Ethereum, Arbitrum, Polygon, BNB Chain, Avalanche, Optimism, Solana, Bitcoin (PSBT), XRP Ledger, Bittensor, Stacks, BOB
Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_spraay-0.2.0.tar.gz.
File metadata
- Download URL: langchain_spraay-0.2.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f2742c70dd3dd006d3b0475d166c6b5aefd0d4133805ea48ac76ffe5284da3
|
|
| MD5 |
02ff88a7091093055bde231652f93275
|
|
| BLAKE2b-256 |
670857d9a82dfcfbd85fe8fb782f5ec07fb49533a42a640c483b08a0fd1d85ea
|
File details
Details for the file langchain_spraay-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_spraay-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d746f89f20c2cee781ca3b87e23ea818eb771f203d681cdda569c8901acf2bab
|
|
| MD5 |
9d3e3181b83b740f1b5e2ef04ee18a48
|
|
| BLAKE2b-256 |
035097772ac5cba7fd90c17e6fd40ce01ff2651e9e66b9f47db4aaecefc5a26d
|