LangChain integration for Sardis - Payment OS for the Agent Economy
Project description
sardis-langchain
LangChain integration for Sardis -- the Payment OS for the Agent Economy.
Gives your LangChain agents the ability to make real, policy-enforced stablecoin payments through Sardis MPC wallets.
Installation
pip install sardis-langchain
Quick Start
from sardis import SardisClient
from sardis_langchain import SardisToolkit
# 1. Initialize Sardis
client = SardisClient(api_key="sk_...")
wallet = client.wallets.create(
name="procurement-agent",
chain="base",
policy="Max $100 per transaction, daily limit $500",
)
# 2. Create LangChain tools
toolkit = SardisToolkit(client=client, wallet_id=wallet.id)
tools = toolkit.get_tools()
# 3. Attach to any LangChain agent
from langchain.agents import AgentExecutor, create_react_agent
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = create_react_agent(llm, tools, your_prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = executor.invoke({
"input": "Pay $30 to Anthropic for API credits and $15 to GitHub for Copilot"
})
Available Tools
| Tool | Name | Description |
|---|---|---|
SardisPayTool |
sardis_pay |
Execute a policy-enforced payment |
SardisCheckBalanceTool |
sardis_check_balance |
Check wallet balance and limits |
SardisCheckPolicyTool |
sardis_check_policy |
Dry-run a payment against policy |
SardisSetPolicyTool |
sardis_set_policy |
Set spending policy from natural language |
SardisListTransactionsTool |
sardis_list_transactions |
View recent transaction history |
Toolkit Options
Full toolkit (all 5 tools)
toolkit = SardisToolkit(client=client, wallet_id=wallet.id)
tools = toolkit.get_tools()
Payment-only tools (3 tools)
tools = toolkit.get_payment_tools() # pay + balance + policy check
Individual tools
from sardis_langchain import SardisPayTool, SardisCheckBalanceTool
pay_tool = SardisPayTool(client=client, wallet_id=wallet.id)
balance_tool = SardisCheckBalanceTool(client=client, wallet_id=wallet.id)
Callback Handler
Track Sardis operations with the built-in callback handler:
from sardis_langchain import SardisCallbackHandler
handler = SardisCallbackHandler()
executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
# After execution, inspect the audit trail
for record in handler.get_payment_records():
print(record)
How Policy Enforcement Works
Every payment goes through Sardis's policy engine before execution:
Agent calls sardis_pay(to="openai.com", amount="25.00")
|
v
Policy Engine checks:
1. Per-transaction limit -> Is $25 under the cap?
2. Balance check -> Enough funds?
3. Total spending limit -> Under lifetime cap?
4. Wallet active -> Is the wallet enabled?
|
v
PASS -> Execute payment, return tx_hash
FAIL -> Return rejection reason (no funds move)
Simulation Mode
By default, SardisClient runs in simulation mode -- all operations execute locally without network calls. This is ideal for prototyping and testing agent payment flows.
# No API key needed for simulation
client = SardisClient()
wallet = client.wallets.create(name="test-agent", chain="base", policy="Max $50/tx")
toolkit = SardisToolkit(client=client, wallet_id=wallet.id)
# All tools work locally -- no real money moves
Links
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 sardis_langchain-1.0.0.tar.gz.
File metadata
- Download URL: sardis_langchain-1.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5fe029218bb1e73828fcaa3aff94a7f434b3bfc9f2cfda0c1f6a336c490ea75
|
|
| MD5 |
60620c201565fa5b25b2903784cb80df
|
|
| BLAKE2b-256 |
299dda258750fc38e4ae3504fb38d5d12f143c343191edf7db678aae929af7af
|
File details
Details for the file sardis_langchain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sardis_langchain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5632fd488949e641af90470b455350b60e811c6a14f2b90dce4142291cab2550
|
|
| MD5 |
2af2f31852705a3a42ec89939d048fd4
|
|
| BLAKE2b-256 |
715b7c7a7e0adea1088573e8930c4cba72701dd9054ec7c4c878182b4d6717a0
|