Skip to content

feat(spraay): Add Spraay batch payment tools for Base#557

Open
Plag (plagtech) wants to merge 1 commit intolangchain-ai:mainfrom
plagtech:feat/add-spraay-batch-payment-tools
Open

feat(spraay): Add Spraay batch payment tools for Base#557
Plag (plagtech) wants to merge 1 commit intolangchain-ai:mainfrom
plagtech:feat/add-spraay-batch-payment-tools

Conversation

@plagtech
Copy link

Add Spraay batch payment tools for Base

Description

This PR adds Spraay batch payment tools to langchain-community, enabling LangChain agents to batch-send ETH and ERC-20 tokens to up to 200 recipients in a single transaction on Base.

Spraay is a multi-chain batch payment protocol that reduces gas costs by ~80% compared to individual transfers. It's deployed across 7+ chains with Base as the primary network.

New Tools

Tool Description
SpraayBatchSendETH Send equal ETH to multiple recipients
SpraayBatchSendToken Send equal ERC-20 tokens (with auto-approval)
SpraayBatchSendETHVariable Send different ETH amounts to each recipient
SpraayBatchSendTokenVariable Send different token amounts (with auto-approval)

New Toolkit

SpraayToolkit — provides all four tools in a single toolkit for agent integration.

Use Cases

  • Payroll: Distribute salaries to team members in one transaction
  • Airdrops: Send tokens to community members efficiently
  • Bounty payments: Pay multiple contributors with varying amounts
  • Revenue sharing: Split earnings among stakeholders

Files Changed

libs/community/langchain_community/tools/spraay/__init__.py
libs/community/langchain_community/tools/spraay/tool.py
libs/community/langchain_community/agent_toolkits/spraay/__init__.py
libs/community/langchain_community/agent_toolkits/spraay/toolkit.py
libs/community/tests/unit_tests/tools/spraay/__init__.py
libs/community/tests/unit_tests/tools/spraay/test_spraay_tools.py

Dependencies

  • web3 (optional, required at runtime)

Environment Variables

Variable Required Description
SPRAAY_PRIVATE_KEY Yes Wallet private key for signing transactions
SPRAAY_RPC_URL No RPC endpoint (default: https://mainnet.base.org)
SPRAAY_CONTRACT_ADDRESS No Override default contract address

Testing

Unit tests included with mocked web3 calls. Tests cover:

  • Tool naming and descriptions
  • Input validation (max 200 recipients, length mismatches)
  • Missing environment variable handling
  • Schema validation

Quick Example

from langchain_community.tools.spraay import SpraayBatchSendETH
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI

tool = SpraayBatchSendETH()
llm = ChatOpenAI(model="gpt-4")
agent = create_agent(llm, [tool])

result = agent.invoke({
    "messages": [("user", "Send 0.01 ETH to 0xAbc... and 0xDef...")]
})

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant