TypeScript SDK
The @backproto/sdk package provides a TypeScript client for interacting with all 22 Backproto smart contracts.
Installation
npm install @backproto/sdk
Features
- Contract ABIs: Pre-compiled ABIs for all 22 contracts
- Type-safe interactions: Full TypeScript types via viem
- 18 action modules: Core BPE + Demurrage + Relay + Lightning + Platform + V2 Economy
- Address registry: Deployed contract addresses for supported networks
- EIP-712 signing: Helpers for attestations and completion receipts
Usage
import { addresses, contracts } from '@backproto/sdk'
// Get contract addresses for Base Sepolia
const { capacityRegistry, backpressurePool, stakeManager } = addresses.baseSepolia
// Use with viem
import { createPublicClient, http } from 'viem'
import { baseSepolia } from 'viem/chains'
const client = createPublicClient({
chain: baseSepolia,
transport: http(),
})
// Read smoothed capacity for a sink
const capacity = await client.readContract({
...contracts.capacityRegistry,
functionName: 'getSmoothedCapacity',
args: [taskTypeId, sinkAddress],
})
Action Modules
Core BPE
| Module | Description |
|---|---|
actions/sink | Register/deregister sinks |
actions/source | Register task types, start/stop payment streams |
actions/pool | Create pools, rebalance, read member units |
actions/stake | Stake/unstake tokens, read capacity cap |
actions/buffer | Deposit to / drain from escrow buffer |
actions/pricing | Report queue load, advance pricing epoch, read prices |
actions/completion | Record completions, advance completion epoch |
actions/aggregator | Submit batched off-chain attestations |
signing | EIP-712 signing helpers |
Domain Extensions
| Module | Description |
|---|---|
actions/demurrage | Wrap/unwrap demurrage tokens, rebase, read decay rates |
actions/relay | Register Nostr relays, join pools, set anti-spam minimums |
actions/lightning | Register Lightning nodes, join routing pools, get optimal routes |
actions/platform | Aggregate reputation, stake discounts, route attestations |
V2 Economy
| Module | Description |
|---|---|
actions/economy | Deploy economies via EconomyFactory, query deployments |
actions/nestedPool | Register child pools, hierarchical rebalance, effective capacity |
actions/quality | Report latency/errors/satisfaction, compute quality scores |
actions/velocityToken | Wrap/unwrap with idle decay, stream exemption checks |
actions/urgencyToken | TTL-stamped deposits, consume, burn, batch operations |
Source
SDK source code is on GitHub.
See also
- Smart Contracts — all 22 deployed contracts with source
- EconomyFactory — one-transaction economy deployment
- Simulation — agent-based validation of BPE claims
- NIP-XX — Nostr relay economics specification
- Get started — deploy an economy in 5 minutes