Metadata-Version: 2.4
Name: zanii-chain
Version: 0.1.0
Summary: Python client SDK for the Zanii L1 blockchain: keys, signing, transactions, session keys, payment streams, and the AgentWallet for AI agents.
Author-email: Zanii <info@zanii.agency>
License-Expression: Apache-2.0
Project-URL: Homepage, https://blockchain.zanii.agency
Project-URL: Explorer, https://blockchain.zanii.agency
Keywords: zanii,blockchain,l1,layer1,agents,payments,ed25519,web3
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pynacl>=1.5
Requires-Dist: blake3>=0.4
Requires-Dist: bech32>=1.2
Requires-Dist: msgpack>=1.0

# zanii-chain

Python client SDK for the **Zanii L1 blockchain** (RPC at
`https://blockchain.zanii.agency`): keys, canonical signing, transactions,
session keys, payment streams, and the `AgentWallet` adapter for AI agents.

> **Not the identity SDK.** The `zanii` package on PyPI is the Zanii
> *agent-identity and proof-of-action* product (did:key, delegation certs,
> receipts, `ledger.zanii.agency`). This package, `zanii-chain`, is the
> *blockchain* client. They are designed to work together.

## Install

```bash
pip install zanii-chain
```

Python 3.10+. Depends on PyNaCl, blake3, bech32, and msgpack.

## Use

```python
from zanii_chain import Wallet, ZaniiClient, ZAN

client = ZaniiClient("https://blockchain.zanii.agency")
wallet = Wallet.generate()                 # or Wallet.from_seed_hex(hex)

client.faucet(wallet.address)              # devnet
client.transfer(wallet, "zan1...", 1 * ZAN)

# agent-native: authorize a scoped session key, then open a payment stream
import time
client.session_authorize(wallet, agent_pubkey,
                         int(time.time()*1000) + 7*86_400_000, 5 * ZAN)
client.stream_open(wallet, "zan1payee...", rate_zi_per_s=1000, deposit_zi=1 * ZAN)
```

## Give an AI agent a wallet

```python
from zanii_chain import AgentWallet

# the owner authorized this agent's session key with a 5 ZAN cap
agent = AgentWallet("https://blockchain.zanii.agency", AGENT_SEED, OWNER_ADDRESS)
agent.pay("zan1provider...", amount_zan=0.25)
agent.open_stream("zan1api...", rate_zan_per_second=0.001, deposit_zan=2.0)

tools = agent.openai_tools()               # JSON tool schemas for any LLM
result = agent.call_tool("balance", "{}")  # dispatch a tool call, get a string
```

`AgentWallet` methods return plain strings for the LLM, and `call_tool` never
raises into the agent loop. LangChain and CrewAI can consume the bound methods
(`agent.pay`, `agent.open_stream`, ...) as plain-function tools.

## Guarantees

Encodings and signatures are byte-identical to the Zanii reference node: a
transaction built here validates and executes on-chain unchanged, and matches
the JavaScript SDK (`@zanii/chain`) byte-for-byte. Amounts are **zi**
(1 ZAN = 10^9 zi), integers only, never floats.

Apache 2.0 &middot; info@zanii.agency &middot; https://blockchain.zanii.agency
