Skip to main content

Open-source Python SDK for AI agents to interact with the Ergo blockchain

Project description

ergo-agent 🤖⛓️

Open-source Python SDK for AI agents on the Ergo blockchain.

Give any LLM agent (Claude, GPT-4, LangChain, CrewAI...) the ability to read wallet balances, fetch live prices, swap tokens on Spectrum DEX — all autonomously, with built-in safety guardrails.

Python 3.10+ License: MIT


Why?

Existing Ergo SDKs (ergpy, fleet-sdk, AppKit) are built for human developers. This SDK is built for AI agents — it speaks the language of function calling, returns structured JSON, and has a safety layer so the agent can't accidentally drain a wallet.


Quickstart

pip install ergo-agent

Read-only (no wallet needed)

from ergo_agent import ErgoNode, Wallet
from ergo_agent.tools import ErgoToolkit, SafetyConfig

node = ErgoNode()
wallet = Wallet.read_only("9f...")  # any address to monitor
toolkit = ErgoToolkit(node=node, wallet=wallet)

# Check address balance
result = toolkit.get_wallet_balance()

# Get live ERG/USD price from Oracle Pool v2
price = toolkit.get_erg_price()

# Get a swap quote from Spectrum DEX
quote = toolkit.get_swap_quote(token_in="ERG", token_out="SigUSD", amount_erg=1.0)

With a wallet (transactions enabled)

from ergo_agent import ErgoNode, Wallet
from ergo_agent.tools import ErgoToolkit, SafetyConfig

node = ErgoNode(node_url="http://your-node:9053", api_key="your-key")
wallet = Wallet.from_node_wallet("9f...")

toolkit = ErgoToolkit(
    node=node,
    wallet=wallet,
    safety=SafetyConfig(
        max_erg_per_tx=5.0,
        max_erg_per_day=50.0,
        allowed_contracts=["spectrum"],
        rate_limit_per_hour=20,
    )
)

# Send ERG
toolkit.send_erg(to="9f...", amount_erg=1.5)

# Swap ERG for a token on Spectrum DEX
toolkit.swap_erg_for_token(token_out="SigUSD", amount_erg=1.0)

Use with LLM frameworks

# OpenAI function calling
tools = toolkit.to_openai_tools()

# Anthropic tool use
tools = toolkit.to_anthropic_tools()

# LangChain
lc_tools = toolkit.to_langchain_tools()

Available Tools

Tool Description Requires Wallet
get_wallet_balance ERG + token balances No
get_erg_price Live ERG/USD from Oracle Pool v2 No
get_swap_quote Spectrum DEX swap quote No
get_mempool_status Pending transactions No
get_safety_status Current spending limits & usage No
send_erg Send ERG to an address Yes
swap_erg_for_token Execute a swap on Spectrum DEX Yes

Architecture

ergo_agent/
├── core/        # ErgoNode client, Wallet, TransactionBuilder, Address utilities, Privacy ($CASH v3)
├── defi/        # Oracle Pool v2, Spectrum DEX adapters
└── tools/       # LLM tool schemas (OpenAI / Anthropic / LangChain) + safety layer

Safety Layer

Every state-changing action passes through SafetyConfig before execution:

SafetyConfig(
    max_erg_per_tx=10.0,                  # hard cap per transaction
    max_erg_per_day=50.0,                 # daily rolling limit
    allowed_contracts=["spectrum"],        # contract whitelist
    rate_limit_per_hour=20,               # max 20 actions/hour
    dry_run=False,                        # set True for dry-run mode
)

Network

By default the SDK connects to the Ergo public API (https://api.ergoplatform.com). For production use or transaction signing, point it at your own node:

node = ErgoNode(node_url="http://your-node:9053", api_key="your-key")

Contributing

This is an open-source project for the Ergo ecosystem. PRs welcome.

Roadmap:

  • v0.1.0 — Core + Oracle + Spectrum + Tool schemas
  • v0.2.0 — $CASH v3 Privacy Protocols (Ring Signatures) (current)
  • v0.3.0 — SigmaUSD + Rosen Bridge adapters + Treasury contracts

License

MIT

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

ergo_agent_sdk-0.2.1.tar.gz (4.6 MB view details)

Uploaded Source

Built Distribution

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

ergo_agent_sdk-0.2.1-py3-none-any.whl (44.3 kB view details)

Uploaded Python 3

File details

Details for the file ergo_agent_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: ergo_agent_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 4.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ergo_agent_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e5c914f9443f467eb0f20a7739050b22fab54ee596fc19847a2a2ca31918c28b
MD5 595cbb2697bcf883eebd15f162e3a7ee
BLAKE2b-256 1cae827335ef556a7c63d439e10999f4f94d76fb667304d95e1412008c2bb1d9

See more details on using hashes here.

File details

Details for the file ergo_agent_sdk-0.2.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for ergo_agent_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5222c042d9125abb2bb352023bbf913339b7b7acd02a92f9be31e4c759295f7a
MD5 ac13b327604253718f1005c9a33bbda3
BLAKE2b-256 47d92d17a776fd7343e0ef3ba25709b254f0a4d5b5b5c4cc86dfcac37c9c297c

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