dreamline-sdk
v0.1.0
Published
On-chain spend governance for AI agents — Dreamline Protocol on BNB Chain
Maintainers
Readme
dreamline-sdk
On-chain spend governance for AI agents — Dreamline Protocol on BNB Chain.
Install
npm install dreamline-sdk
Quick Start
const { DreamlineSDK } = require('dreamline-sdk');
const dreamline = new DreamlineSDK({ privateKey: process.env.AGENT_WALLET_KEY });
// Request approval before any payment const result = await dreamline.requestApproval('api.coingecko.com', 100); // $1.00
if (result.approved) { console.log('Approved:', result.approvalId); // proceed with payment } else if (result.circuitBreaker) { console.error('Agent auto-paused — too many violations'); } else if (result.pending) { console.log('Awaiting human approval:', result.approvalId); } else { console.error('Blocked:', result.reason); }
What is Dreamline?
Dreamline Protocol is an on-chain spend governance layer for AI agents on BNB Chain. It enforces spending policies — budgets, limits, destination whitelists — trustlessly via smart contracts. No server. No API key. Just blockchain.
Key features:
- On-chain policy enforcement — daily budgets, per-tx limits, destination whitelists
- Circuit Breaker — auto-pauses agents after 3 violations in 10 minutes (first on-chain circuit breaker for AI agents)
- Human approval — transactions above threshold require explicit operator approval
- Protocol fee — disabled by default (Uniswap-style switch)
- ERC-8004 compatible — works with agent identity standard
Smart Contracts (BNB Chain Testnet)
DreamlineVerifier: 0x1eA365E30e91C74fc50d62Ec5C60c9c029Ee8B58 DreamlineRegistry: 0x71dA6F5b106E3Fb0B908C7e0720aa4452338B8BE DreamlineGovernance: 0x5a57Efb32BD68437e1A200C656E580C006b2E6A6
API Reference
new DreamlineSDK(config)
const dreamline = new DreamlineSDK({ privateKey: '0x...', rpc: 'https://...', verifierAddress: '0x...', registryAddress: '0x...' });
requestApproval(destination, amountUsd)
const result = await dreamline.requestApproval('uniswap.org', 5000); // $50.00
result.approved — payment approved, use result.approvalId result.pending — awaiting human approval result.denied — blocked by policy result.circuitBreaker — agent paused after too many violations result.reason — reason for denial result.txHash — BNB Chain transaction hash
executePayment(approvalId)
const exec = await dreamline.executePayment(result.approvalId); exec.success — true if executed exec.txHash — BNB Chain transaction hash
getPolicy(agentAddress?)
const policy = await dreamline.getPolicy(); policy.dailyBudgetUsd — daily spending limit policy.singleTxLimitUsd — per-transaction limit policy.approvalThresholdUsd — manual approval threshold policy.active — agent is registered and active
getCircuitBreakerStatus(agentAddress?)
const cb = await dreamline.getCircuitBreakerStatus(); cb.paused — agent is paused cb.denialCount — current denials in window cb.minutesUntilUnpause — minutes until auto-unpause cb.totalTriggeredCount — total times circuit breaker triggered
isDestinationAllowed(destination)
const allowed = await dreamline.isDestinationAllowed('free-crypto.xyz'); // false
getDailySpend(agentAddress?)
const spent = await dreamline.getDailySpend(); // e.g. 42.50
Integration Example — ERC-8004 Agent
const { DreamlineSDK } = require('dreamline-sdk');
class MyAgent { constructor() { this.dreamline = new DreamlineSDK({ privateKey: process.env.AGENT_WALLET_KEY }); }
async pay(destination, amountUsd, execute) { const cb = await this.dreamline.getCircuitBreakerStatus(); if (cb?.paused) { throw new Error('Agent paused — ' + cb.minutesUntilUnpause + ' minutes remaining'); }
const approval = await this.dreamline.requestApproval(destination, amountUsd);
if (!approval.approved) {
throw new Error('Payment blocked: ' + approval.reason);
}
await execute();
await this.dreamline.executePayment(approval.approvalId);
return { txHash: approval.txHash };} }
Circuit Breaker
The circuit breaker is the first on-chain automatic safety mechanism for AI agents. If an agent triggers 3 denied payments within 10 minutes it is automatically paused on-chain for 1 hour. No server. No human needed. Enforced by smart contract math.
3 denials in 10 minutes → auto-paused for 1 hour Operator can reset manually via resetCircuitBreaker() Auto-unpause after cooldown
License
BUSL-1.1 — Business Source License. Free for non-commercial use. Commercial use requires a license from Dreamline Labs.
Links
- Dreamline Protocol: https://dreamline.ai
- BNB Chain Testnet Explorer: https://testnet.bscscan.com/address/0x1eA365E30e91C74fc50d62Ec5C60c9c029Ee8B58
- The Graph Subgraph: https://thegraph.com/studio/subgraph/dreamline-protocol
