Skip to main content

Python SDK for the Baud M2M Agent Ledger

Project description

baud-sdk

Python SDK for the Baud M2M Agent Ledger.

Installation

pip install baud-sdk

This installs everything needed — no external binaries required.

Quick Start

from baud_sdk import BaudClient, NativeKeyPair, QUANTA_PER_BAUD

# Generate a new agent identity (pure Python, no CLI needed)
kp = NativeKeyPair.generate()
print(f"Address: {kp.address_hex}")
print(f"Secret:  {kp.secret_hex}")

# Connect to a node with pure Python signing
client = BaudClient.from_secret(kp.secret_hex, node_url="http://localhost:8080")

# Send 1 BAUD
result = client.native_send(to="<recipient-address>", amount=QUANTA_PER_BAUD)
print(f"TX hash: {result['tx_hash']}")

# Check balance
balance = client.balance(kp.address_hex)
print(f"Balance: {balance} quanta = {balance / QUANTA_PER_BAUD} BAUD")

# Create escrow
client.native_create_escrow(
    recipient="<worker-address>",
    amount=500 * QUANTA_PER_BAUD,
    preimage="proof_of_delivery",
    deadline=1700000000000,
)

# Register agent identity
client.native_register_agent(
    name="my-agent",
    endpoint="https://api.myagent.ai",
    capabilities=["llm", "inference"],
)

For AI Agents

An AI agent only needs to run pip install baud-sdk — no Rust, no compiling, no CLI binary.

from baud_sdk import BaudClient

# Agent connects with its secret key
client = BaudClient.from_secret("your_secret_key_hex", node_url="http://node-ip:8080")

# Pay for a service
client.native_send(to="service_provider_address", amount=10**18, memo="image-gen-job-42")

# Check balance
client.balance(client.address)

API Reference

NativeKeyPair (recommended — pure Python)

  • NativeKeyPair.generate() — Generate a new random keypair
  • NativeKeyPair.from_secret_hex(hex) — Restore from a hex secret key
  • .address_hex — Hex-encoded agent address
  • .secret_hex — Hex-encoded secret key
  • .sign(message) — Sign raw bytes

BaudClient

Create:

  • BaudClient.from_secret(secret_hex, node_url, chain_id) — Pure Python client (recommended)
  • BaudClient(node_url, keypair=kp) — CLI-based client (legacy)

Query methods:

  • client.status() — Node status
  • client.account(address) — Account details
  • client.balance(address) — Balance in quanta
  • client.nonce(address) — Current nonce
  • client.get_escrow(id) — Escrow details
  • client.get_tx(hash) — Transaction lookup
  • client.mempool() — Pending transactions

Native signing methods (pure Python, recommended):

  • client.native_send(to, amount, memo=None, nonce=None)
  • client.native_create_escrow(recipient, amount, preimage, deadline, nonce=None)
  • client.native_release_escrow(escrow_id, preimage, nonce=None)
  • client.native_refund_escrow(escrow_id, nonce=None)
  • client.native_register_agent(name, endpoint, capabilities, nonce=None)

CLI-based methods (requires baud binary, legacy):

  • client.send(to, amount, memo=None, nonce=None)
  • client.create_escrow(recipient, amount, preimage, deadline, nonce=None)
  • client.release_escrow(escrow_id, preimage, nonce=None)
  • client.refund_escrow(escrow_id, nonce=None)
  • client.register_agent(name, endpoint, capabilities, nonce=None)

Constants

  • QUANTA_PER_BAUD = 10**18

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

baud_sdk-0.2.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

baud_sdk-0.2.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file baud_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: baud_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for baud_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c79ddf42bc3b90cf2fb6c02b0b77fef06b8f32853607640c9d908b8563c6472c
MD5 399c777a19d33ba4d3ddeac69271525b
BLAKE2b-256 c6989e51fea4fbb37f0f61abe1da5f91d8d34308ef2b4d7f8e35ace0176a412a

See more details on using hashes here.

File details

Details for the file baud_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: baud_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for baud_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 015f7c97dd180ff06d94bf0c0ffb5ef87d24bb402dc4a37884f84ae29882b28d
MD5 cb96c9c534fa6c968337a5f8f887c6b3
BLAKE2b-256 bfbbed73b6c7d997b288749a348d5a259b8a0b05383d6780c39aaf606e584a66

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