Skip to main content

Python SDK for Axon — treasury and payment infrastructure for autonomous AI agents

Project description

axonfi

Python SDK for Axon — treasury and payment infrastructure for autonomous AI agents.

Axon lets bot operators deploy non-custodial vaults, register bot public keys, define spending policies, and let their bots make gasless payments — without bots ever touching private keys or gas.

Installation

pip install axonfi

Quick Start

Option 1: Keystore file + passphrase (recommended)

When you register a bot on the Axon dashboard, it generates a keystore JSON file. This is the safest way to load a bot key — the private key stays encrypted on disk and only lives in memory while the bot runs.

import json
from eth_account import Account
from axonfi import AxonClient, Chain, Token

# Load encrypted keystore file (downloaded from the dashboard)
with open("bot-keystore.json") as f:
    keystore = json.load(f)

# Decrypt with your passphrase (set when you registered the bot)
private_key = Account.decrypt(keystore, "your-passphrase")

client = AxonClient(
    vault_address="0x...",
    chain_id=Chain.BaseSepolia,
    bot_private_key="0x" + private_key.hex(),
)

# Pay 5 USDC — SDK handles decimals automatically
result = await client.pay(
    to="0x...recipient...",
    token=Token.USDC,
    amount=5,
    memo="API call #1234 — weather data",
)

print(result.status, result.tx_hash)

Option 2: Raw private key (for quick testing)

from axonfi import AxonClient, Chain

client = AxonClient(
    vault_address="0x...",
    chain_id=Chain.BaseSepolia,
    bot_private_key="0x...",  # From env var or .env file — never hardcode
)

result = await client.pay(to="0x...", token=Token.USDC, amount=5)

Synchronous Usage (LangChain, CrewAI)

Both options work with the sync client too — just swap AxonClient for AxonClientSync:

from axonfi import AxonClientSync, Chain, Token

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

result = client.pay(to="0x...", token=Token.USDC, amount=5)

Features

  • EIP-712 signing for all intent types (payment, execute, swap)
  • Async + sync clients — use AxonClient (async) or AxonClientSync
  • Human-friendly amounts — pass 5 or "5.2" instead of 5000000
  • Token registry — use "USDC" or Token.USDC instead of addresses
  • Full relayer API — pay, execute DeFi protocols, swap, poll, check balances

API Reference

AxonClient / AxonClientSync

Method Description
pay(to, token, amount, ...) Create, sign, and submit a payment
execute(protocol, call_data, token, amount, ...) DeFi protocol interaction
swap(to_token, min_to_amount, ...) In-vault token swap
get_balance(token) Vault balance for a token
get_balances(tokens) Multiple balances in one call
is_active() Whether this bot is active
is_paused() Whether the vault is paused
get_vault_info() Owner, operator, paused, version
can_pay_to(destination) Destination whitelist/blacklist check
poll(request_id) Poll async payment status

Signing Utilities

from axonfi import sign_payment, encode_ref, PaymentIntent

ref = encode_ref("my memo")
intent = PaymentIntent(bot="0x...", to="0x...", token="0x...", amount=1000000, deadline=1700000000, ref=ref)
signature = sign_payment(private_key, vault_address, chain_id, intent)

Constants

from axonfi import Chain, USDC, Token, KNOWN_TOKENS

chain_id = Chain.BaseSepolia       # 84532
usdc_addr = USDC[chain_id]        # 0x036CbD...
decimals = KNOWN_TOKENS["USDC"].decimals  # 6

Supported Chains

Chain ID Status
Base 8453 Mainnet
Base Sepolia 84532 Testnet
Arbitrum One 42161 Mainnet
Arbitrum Sepolia 421614 Testnet

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

axonfi-0.1.4.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

axonfi-0.1.4-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file axonfi-0.1.4.tar.gz.

File metadata

  • Download URL: axonfi-0.1.4.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for axonfi-0.1.4.tar.gz
Algorithm Hash digest
SHA256 608b72a5e661340ba6d4b508a014075ecb3f70c31eeabae77101405e1446013e
MD5 56562276b4cdfe0b131f81fd45e29a45
BLAKE2b-256 05b3249a18e13500f545362bf06f7dd6b4fb97beee43fe69451a2efc00c0aeb1

See more details on using hashes here.

File details

Details for the file axonfi-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: axonfi-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for axonfi-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 958243bd3412afa81c64bade611a7ee8d7d624bf633bfd3c56ad176c205ae3b3
MD5 cb4cf0552e19b7ff84d3eb5dd89883d4
BLAKE2b-256 71537ebeafc42ba31adc58695265bcc8c2f9806689dcdd17c8727869b62c420f

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