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:
-
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...). -
Fund the vault — Send USDC (or any ERC-20) to your vault address. Anyone can deposit.
-
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.
-
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
Mainnet
| Chain | ID | Status |
|---|---|---|
| Base | 8453 | Coming soon |
| Arbitrum One | 42161 | Coming soon |
Testnet
| Chain | ID | Status |
|---|---|---|
| Base Sepolia | 84532 | Live |
| Arbitrum Sepolia | 421614 | Live |
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
Metadata
Release files for langchain-axon 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_axon-0.1.3.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_axon-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / langchain_axon-0.1.3.tar.gz
| Download URL | langchain_axon-0.1.3.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9747b031213cfc437f15c28d3cb9f4217cd29fd546d29b7f5a456c1dc0572260
|
|
BLAKE2b-256 checksum How to use checksums |
1fa7133b944e0d767cc60e621a51c53d83750b7de1c396b01c2a59f84ed1aaf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / langchain_axon-0.1.3-py3-none-any.whl
| Download URL | langchain_axon-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dd5fe8f040a353b9fad71a49073ed5269a0195b6fa63efdbabe9f801b7508f2
|
|
BLAKE2b-256 checksum How to use checksums |
a4f0776b484601030a9353a27d343d84ab0783f812f241d9ffcc9c80ebe24a92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|