SDK
Everything the arkiv-triggers package exports for apps, with signatures.
npm install arkiv-triggers @arkiv-network/sdk@0.8.1 viemApps import from arkiv-triggers. The worker is a separate entry point, arkiv-triggers/worker, so apps
that only write rules never load it.
createTriggers
const triggers = createTriggers(options?)Prop
Type
Methods
| Method | Returns | Notes |
|---|---|---|
createRule(input) | { key, txHash, warnings } | Validates, checks an expire target exists, writes one rule |
createRules(inputs) | { keys, txHash, warnings } | Several rules in one transaction |
deleteRule(key) | { txHash } | |
listRules({ creator, app? }) | RuleWithStatus[] | Each with status, deadline and its receipts, sorted by deadline |
getRule(key) | AuditTrail or undefined | { rule, status, deadline, targetExpiresAt, claims, receipts } |
listReceipts({ rule?, creator?, sinceBlock? }) | Receipt[] | Newest first |
listWorkers({ operator? }) | WorkerInfo[] | From heartbeats, with online and operatorVerified |
watch(handlers) | () => void (stop) | Live receipts, rules, heartbeats over one WebSocket |
clock() | { block, timeMs, blockSeconds } | The chain's current block and its time |
toBlock(date) | Promise<bigint> | The block expected at a date |
toDate(block) | Promise<Date> | The time a block is expected at |
reader | public client | The client reads go through |
watch handlers
Prop
Type
Rule input
type RuleInput = {
trigger: { on: 'expire'; target: Hex; offset?: bigint } | { on: 'block'; fireAt: bigint; offset?: bigint }
action: 'telegram' | 'webhook' | 'receipt' | 'extend'
name?: string
message?: string // telegram, webhook; {entity} {time} {rule}
chat?: string // telegram; sealed with sealForWorker
url?: string // webhook; https only, public
extendDays?: number // extend
worker?: 'any' | Hex // default 'any'
retries?: number // 0 to 10, default 3
app?: string
}Other exports
| Export | What it is |
|---|---|
sealForWorker(text, workerSealKey) | Seal a chat ID to one worker. See Sealing |
verifyWebhook(rawBody, signature, trusted) | { ok: true, worker } or { ok: false, reason }. Server side |
WEBHOOK_HEADERS | signature, worker, rule, event header names |
validateRule(input) | Throws SchemaError with a readable message |
ruleWarnings(input) | Non-blocking warnings, such as a URL that looks secret |
fillMessage(message, values) | Fills {entity}, {time}, {rule} |
toBlock(date, clock), toDate(block, clock) | Pure conversions, no network call |
ACTIONS, ACTION_NAMES | The action menu: label, icon, description, fields, who can fire it |
TEMPLATES | Ready-made rules the dashboard offers |
TYPES | Entity types: trg.rule, trg.claim, trg.receipt, trg.worker |
LIFETIMES, BLOCK_SECONDS, SCHEMA_VERSION | Lifetimes, 2-second blocks, format version 1 |
operatorVerified(heartbeat) | Checks a worker's operator signature |
DEFAULT_RPC_URL, DEFAULT_WS_URL | Tiramisu endpoints |
TriggersError, SchemaError, SealError, QueryTimeoutError | Error classes |
Types: Rule, RuleInput, RuleWithStatus, Receipt, Claim, Heartbeat, WorkerInfo,
AuditTrail, Triggers, TriggersOptions, WatchHandlers, BlockClock, WebhookBody, VerifyResult.