Skip to main content

LangChain toolkit for Axon — treasury and payment infrastructure for autonomous AI agents

Project description

langchain-axon

LangChain toolkit for Axon — treasury and payment infrastructure for autonomous AI agents.

Gives your LangChain agent 7 tools: pay, check balance, swap tokens, execute DeFi protocols, poll async requests, get vault info, and handle x402 paywalls.

Install

pip install langchain-axon

Prerequisites

Before using this toolkit, you need an Axon vault and a registered bot:

  1. Deploy a vault — Go to app.axonfi.xyz, connect your wallet, and deploy a vault. The vault is a non-custodial smart contract that holds your funds. You'll get a vault address (e.g. 0xb8e3...).

  2. Fund the vault — Send USDC (or any ERC-20) to your vault address. Anyone can deposit.

  3. Register a bot — In the dashboard, go to your vault → Bots → Add Bot. You can generate a new keypair (downloads a keystore file) or bring your own public key. Set spending limits and policies.

  4. Get the bot key — Your agent needs the bot's private key to sign payment intents. Either use the keystore file + passphrase, or export the raw private key.

Your wallet (vault owner) stays secure — the bot key can only sign intents within the policies you set. The bot never touches gas or holds funds.

Supported chains: Base, Arbitrum, Optimism, Polygon (mainnet + testnets).

Quick Start

from langchain_axon import AxonToolkit
from langchain_anthropic import ChatAnthropic
from axonfi import Chain

toolkit = AxonToolkit(
    vault_address="0x...",
    chain_id=Chain.BaseSepolia,
    bot_private_key="0x...",
)

llm = ChatAnthropic(model="claude-sonnet-4-20250514")
agent = llm.bind_tools(toolkit.get_tools())

Keystore Authentication

toolkit = AxonToolkit(
    vault_address="0x...",
    chain_id=Chain.Base,
    bot_keystore="bot-keystore.json",
    bot_passphrase="my-secret-passphrase",
)

Environment Variables

AXON_VAULT_ADDRESS=0x...
AXON_CHAIN_ID=84532
AXON_BOT_PRIVATE_KEY=0x...
# or
AXON_BOT_KEYSTORE_PATH=bot-keystore.json
AXON_BOT_PASSPHRASE=my-secret-passphrase

Tools

Tool Description
axon_pay Send a payment from the vault
axon_balance Check vault token balance
axon_swap In-vault token rebalance
axon_execute DeFi protocol interaction (approve → call → revoke)
axon_poll Poll async payment/swap/execute status
axon_vault_info Get vault status, owner, paused state
axon_x402 Handle HTTP 402 Payment Required paywalls

Individual Tools

from langchain_axon import AxonPay, AxonBalance
from axonfi import AxonClientSync, Chain

client = AxonClientSync(
    vault_address="0x...",
    chain_id=Chain.BaseSepolia,
    bot_private_key="0x...",
)

pay_tool = AxonPay(client=client)
balance_tool = AxonBalance(client=client, chain_id=Chain.BaseSepolia)

Full Agent Example

import os
from langchain_axon import AxonToolkit
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage, SystemMessage, ToolMessage
from axonfi import Chain

toolkit = AxonToolkit(
    vault_address=os.environ["AXON_VAULT_ADDRESS"],
    chain_id=Chain.BaseSepolia,
    bot_private_key=os.environ["AXON_BOT_PRIVATE_KEY"],
)

tools = toolkit.get_tools()
llm = ChatAnthropic(model="claude-sonnet-4-20250514", temperature=0)
llm_with_tools = llm.bind_tools(tools)

messages = [
    SystemMessage(content="You are an AI agent with an Axon payment vault."),
    HumanMessage(content="Check my USDC balance then send 1 USDC to 0xRecipient"),
]

# Agent loop
while True:
    response = llm_with_tools.invoke(messages)
    messages.append(response)

    if not response.tool_calls:
        print(response.content)
        break

    for call in response.tool_calls:
        tool = next(t for t in tools if t.name == call["name"])
        result = tool.invoke(call["args"])
        messages.append(ToolMessage(content=result, tool_call_id=call["id"]))

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

langchain_axon-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

langchain_axon-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_axon-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_axon-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for langchain_axon-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7db3ec43bedbc67b02847f9bb932370b8c04afba2a03eba39a4e26498349fb8b
MD5 a23fea21092151ff0d7237369335ee54
BLAKE2b-256 21d640b5a27487379c4f1dd3451fcf7a77dcbea29782de80320a103fcaf8d021

See more details on using hashes here.

File details

Details for the file langchain_axon-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langchain_axon-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for langchain_axon-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5cbc74c46e1174aab011dd3f9ea0fd217ae454260fc3cbc0b02843ac363aeeec
MD5 785ccb1ef2a20c73b6d4545e267a7192
BLAKE2b-256 041bdf7e6dfe7d190cef0ce89656e913e7d05a811cd2e3e45c8e492648a65b87

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