Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sardis_langchain-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sardis_langchain-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file sardis_langchain-0.1.0.tar.gz.

File metadata

  • Download URL: sardis_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sardis_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1613393a36d9e822870b3867fdc3fc56f0e1f5c955163f31e7b9fb19bbc9392a
MD5 be514a861f918f19eb47430af847f1c4
BLAKE2b-256 b3436db762705bc4ba0567813f841f1ff5b84704c0b4acc593785f852e105bb3

See more details on using hashes here.

File details

Details for the file sardis_langchain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sardis_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32b746f5b20f21bf6fad51c7e51a0247257251e127a462fb1b05f88460a7f13c
MD5 c85edc4e09a667ec516a9d8f8cc5ed48
BLAKE2b-256 7bcfcd80a5b2af2360f97b0cd4de2bd92b6026dac34f8cc5e2b652ce06f84abd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page