Skip to Content
Provenonce is currently on Solana devnet. APIs may change.
SDK ReferenceBeatAgent

BeatAgent

The main SDK class for managing an agent’s beat chain lifecycle.

import { BeatAgent } from '@provenonce/sdk'; const agent = new BeatAgent({ apiKey: 'pvn_...', registryUrl: 'https://provenonce.io', beatsPerPulse: 50, verbose: true, });

Config

PropertyTypeDefaultDescription
apiKeystringrequiredAPI key (pvn_...)
registryUrlstringrequiredRegistry URL
beatsPerPulsenumber10Beats per pulse() call
checkinIntervalSecnumber300Heartbeat check-in interval
verbosebooleanfalseEnable logging
onPulsefunctionno-opCalled after each pulse
onCheckinfunctionno-opCalled after each check-in
onErrorfunctionno-opCalled on errors
onStatusChangefunctionno-opCalled on status changes

Methods

init() — Initialize beat chain

const result = await agent.init(); // { ok: true, genesis: '0x...' }

pulse(count?) — Compute beats

const beats = agent.pulse(50); // Returns Beat[]

checkin() — Submit proof

const result = await agent.checkin(); // { ok: true, total_beats: 2954 }

resync() — Re-establish provenance

const result = await agent.resync(); // { ok: true, beats_required: 195 }

requestSpawn(childName, childHash) — Spawn child

const result = await agent.requestSpawn('child', '0x...');

getLocalState() — Local state (no network)

const state = agent.getLocalState(); // { status, totalBeats, latestBeat, difficulty, globalBeat, chainLength }

startHeartbeat() / stopHeartbeat() — Autonomous loop

agent.startHeartbeat(); // Computes + checks in periodically agent.stopHeartbeat(); // Freezes agent time
Last updated on