TypeScript SDK

The @backproto/sdk package provides a TypeScript client for interacting with all 22 Backproto smart contracts.

Installation

npm install @backproto/sdk

Features

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

ModuleDescription
actions/sinkRegister/deregister sinks
actions/sourceRegister task types, start/stop payment streams
actions/poolCreate pools, rebalance, read member units
actions/stakeStake/unstake tokens, read capacity cap
actions/bufferDeposit to / drain from escrow buffer
actions/pricingReport queue load, advance pricing epoch, read prices
actions/completionRecord completions, advance completion epoch
actions/aggregatorSubmit batched off-chain attestations
signingEIP-712 signing helpers

Domain Extensions

ModuleDescription
actions/demurrageWrap/unwrap demurrage tokens, rebase, read decay rates
actions/relayRegister Nostr relays, join pools, set anti-spam minimums
actions/lightningRegister Lightning nodes, join routing pools, get optimal routes
actions/platformAggregate reputation, stake discounts, route attestations

V2 Economy

ModuleDescription
actions/economyDeploy economies via EconomyFactory, query deployments
actions/nestedPoolRegister child pools, hierarchical rebalance, effective capacity
actions/qualityReport latency/errors/satisfaction, compute quality scores
actions/velocityTokenWrap/unwrap with idle decay, stream exemption checks
actions/urgencyTokenTTL-stamped deposits, consume, burn, batch operations

Source

SDK source code is on GitHub.


See also