TypeScript SDK
The @puraxyz/sdk package provides a TypeScript client for interacting with all 32 Pura smart contracts.
Installation
Features
- Contract ABIs: pre-compiled ABIs for all 35 contracts
- Type-safe interactions: full TypeScript types via viem
- 23 action modules: Core BPE + Demurrage + Relay + Lightning + Platform + V2 Economy + Thermodynamic
- Address registry: deployed contract addresses for supported networks
- EIP-712 signing: helpers for attestations and completion receipts
Usage
import { addresses, contracts } from '@puraxyz/sdk'
const { capacityRegistry, backpressurePool, stakeManager } = addresses.baseSepolia
import { createPublicClient, http } from 'viem'
import { baseSepolia } from 'viem/chains'
const client = createPublicClient({
chain: baseSepolia,
transport: http(),
})
const capacity = await client.readContract({
...contracts.capacityRegistry,
functionName: 'getSmoothedCapacity',
args: [taskTypeId, sinkAddress],
})
Action Modules
Core BPE
Domain Extensions
V2 Economy
Thermodynamic & Monitoring
High-level client
The SDK also exports a high-level client with three convenience functions that wrap the lower-level action modules:
import { route, deploy, monitor } from '@puraxyz/sdk'
const result = await route({ apiKey: 'pura_...', messages: [...] })
const txs = await deploy(wallet, addresses, { taskTypeId, initialCapacity: 100n, stakeAmount: 400n * 10n ** 18n })
const state = await monitor(client, addresses)
Source
SDK source code is on GitHub.
See also