Skip to main content

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

Metadata

Release files for sardis-langchain 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sardis-langchain 1.0.0
File Size Uploaded
sardis_langchain-1.0.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sardis-langchain 1.0.0
File Interpreter ABI Platform
sardis_langchain-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / sardis_langchain-1.0.0.tar.gz

Download URL sardis_langchain-1.0.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a5fe029218bb1e73828fcaa3aff94a7f434b3bfc9f2cfda0c1f6a336c490ea75
BLAKE2b-256 checksum
How to use checksums
299dda258750fc38e4ae3504fb38d5d12f143c343191edf7db678aae929af7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / sardis_langchain-1.0.0-py3-none-any.whl

Download URL sardis_langchain-1.0.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5632fd488949e641af90470b455350b60e811c6a14f2b90dce4142291cab2550
BLAKE2b-256 checksum
How to use checksums
715b7c7a7e0adea1088573e8930c4cba72701dd9054ec7c4c878182b4d6717a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page