Python SDK for the DR-Pay protocol — AI agent payments on DigiByte
Project description
digirails
Python SDK for the DR-Pay protocol — permissionless AI agent payments on DigiByte.
What is this?
DigiRails enables autonomous AI agents to discover, negotiate with, and pay each other using DigiByte's Layer 1 blockchain. This SDK implements the DR-Pay protocol: the 4-message payment flow, agent identity, service manifests, and on-chain data encoding.
Every payment settles on-chain as a standard DigiByte transaction. No sidechains, no Layer 2, no API keys.
Install
pip install digirails
Quick Start
Buyer — purchase a service in one call
import asyncio
from digirails import Agent, REGTEST
async def main():
async with Agent.generate(
network=REGTEST,
rpc_url="http://digirails:digirails@127.0.0.1:18443",
) as buyer:
result = await buyer.request_service(
seller_url="http://127.0.0.1:9001",
service_id="echo",
params={"message": "Hello from DigiRails!"},
max_amount="0.01",
)
print(result.result)
asyncio.run(main())
Seller — offer a service
import asyncio
from digirails import Agent, ServiceCategory, REGTEST
def handle_echo(params: dict) -> dict:
return {"echo": params.get("message", "")}
async def main():
seller = Agent.generate(
network=REGTEST,
rpc_url="http://digirails:digirails@127.0.0.1:18443",
)
seller.register_service(
service_id="echo",
handler=handle_echo,
price="0.001",
category=ServiceCategory.GENERAL_COMPUTE,
)
await seller.serve(port=9001)
await asyncio.Event().wait() # Run forever
asyncio.run(main())
What happens under the hood
Buyer Seller
| |
| GET /.well-known/digirails.json |
|----------------------------------->| 1. Discover manifest
|<-----------------------------------|
| |
| POST /drpay/request |
|----------------------------------->| 2. SERVICE_REQUEST
|<-----------------------------------| 3. PAYMENT_INVOICE
| |
| [build, sign, broadcast tx] |
| |
| POST /drpay/broadcast |
|----------------------------------->| 4. PAYMENT_BROADCAST
| | 5. Verify payment
| | 6. Execute service
|<-----------------------------------| 7. SERVICE_DELIVERY
Regtest Demo
Run the self-contained demo with two agents transacting locally:
# 1. Start DigiByte Core in regtest mode
digibyted -regtest -daemon -server \
-rpcuser=digirails -rpcpassword=digirails \
-txindex=1 -fallbackfee=0.0001
# 2. Run the demo
python examples/regtest_demo.py
Features
- Light mode: No DigiByte node required. Connects to
rpc.digirails.orgor any RPC endpoint. - Async-native: Built on asyncio + aiohttp.
- Type-safe: Pydantic models for all protocol messages.
- 4 dependencies: pydantic, aiohttp, cryptography, ecdsa. All with pre-built wheels.
- SegWit transactions: BIP-143 signing for P2WPKH inputs.
- Encrypted keystore: AES-256-GCM encrypted key files.
- All 18 service categories from the DR-Pay spec.
Protocol Version
Implements DR-Pay specification v0.3.0.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file digirails-0.1.0.tar.gz.
File metadata
- Download URL: digirails-0.1.0.tar.gz
- Upload date:
- Size: 38.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25ce8da8048ff8808d693e29d13ca9a925a406a64a0b8377f2cf46b837212365
|
|
| MD5 |
ef4ac6e167deff426e328ec002523224
|
|
| BLAKE2b-256 |
e527d3b817cc054b40de6471c9b638e282bc51e043dca9f0ebe1e5387c243837
|
File details
Details for the file digirails-0.1.0-py3-none-any.whl.
File metadata
- Download URL: digirails-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31a73f6c325bc7450f5bca83ccd222a684244b1f86ca7734550f3911f1e9f163
|
|
| MD5 |
86cbece2bf4578370c22b2fd70cb5001
|
|
| BLAKE2b-256 |
732a9f522f979da498c053cc5b8596631d79102f666d5c3a1d9cf4e534d0f71c
|