digirails
v0.1.0
Published
DigiRails SDK — Payment infrastructure for autonomous AI agents on DigiByte L1
Maintainers
Readme
digirails
Node.js/TypeScript 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
npm install digirailsQuick Start
Buyer — purchase a service in one call
import { Agent, REGTEST } from 'digirails';
const buyer = Agent.generate({
network: REGTEST,
rpcUrl: 'http://127.0.0.1:18443',
rpcUsername: 'digirails',
rpcPassword: 'digirails',
});
const result = await buyer.requestService({
sellerUrl: 'http://127.0.0.1:9001',
serviceId: 'echo',
serviceParams: { message: 'Hello from DigiRails!' },
maxAmount: '0.01',
});
console.log(result.result);
await buyer.close();Seller — offer a service
import { Agent, ServiceCategory, REGTEST } from 'digirails';
const seller = Agent.generate({
network: REGTEST,
rpcUrl: 'http://127.0.0.1:18443',
rpcUsername: 'digirails',
rpcPassword: 'digirails',
});
seller.registerService({
serviceId: 'echo',
handler: async (params) => ({ echo: params?.message ?? '' }),
price: '0.001',
category: ServiceCategory.GENERAL_COMPUTE,
});
await seller.serve('0.0.0.0', 9001);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_DELIVERYFeatures
- Light mode: No DigiByte node required. Connects to
rpc.digirails.orgor any RPC endpoint. - Async-native: Built on native
fetchandasync/await. - Type-safe: Zod-validated protocol messages with full TypeScript types.
- 3 dependencies: @noble/curves, @noble/hashes, zod. Zero native modules.
- 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
