Python SDK
The Python SDK offers the same core features as the TypeScript SDK for
agents written in Python 3.11 or later. It uses web3.py and signs locally with
eth-account.
Install
Version 3.0.0 is not on PyPI yet. Install it from a checkout of the
repository:
pip install ./packages/sdk-pyConnect and pay
import os
from eth_account import Account
from arcanum_sdk import ArcanumClient, arc_mainnet
from arcanum_sdk.chains import ARC_MAINNET_RPC_URL
arc = ArcanumClient(
wallet_address=os.environ["GUARDED_WALLET"],
agent_signer=Account.from_key(os.environ["AGENT_PRIVATE_KEY"]),
chain=arc_mainnet,
rpc_url=os.environ.get("ARC_MAINNET_RPC_URL", ARC_MAINNET_RPC_URL),
)
result = arc.execute_usdc(
to="0x...",
amount=50_000_000, # 50 USDC, 6 decimals
reason="OpenAI API top-up",
metadata={"category": "API"},
)For testing, use arc_testnet and ARC_TESTNET_RPC_URL from arcanum_sdk.chains.
Async
from arcanum_sdk import AsyncArcanumClient
arc = AsyncArcanumClient(
wallet_address=os.environ["GUARDED_WALLET"],
agent_signer=Account.from_key(os.environ["AGENT_PRIVATE_KEY"]),
chain=arc_mainnet,
rpc_url=os.environ.get("ARC_MAINNET_RPC_URL", ARC_MAINNET_RPC_URL),
)Errors
PolicyDeniedError means the policy refused the payment. TransferRevertedError means the
transaction was sent and reverted onchain; keep the transaction details and show the revert
reason. Payment intents use reference (formerly idempotency_key).