Skip to content
Algorand Developer Portal

AlgoKit Subscriber TypeScript

bash npm install @algorandfoundation/algokit-subscriber
import { AlgorandClient } from '@algorandfoundation/algokit-utils';
import { AlgorandSubscriber } from '@algorandfoundation/algokit-subscriber';
import { TransactionType } from '@algorandfoundation/algokit-utils/transact';
const algorand = AlgorandClient.testNet();
const subscriber = new AlgorandSubscriber(
{
filters: [
{
name: 'filter1',
filter: {
type: TransactionType.pay,
sender: 'ABC...',
},
},
],
watermarkPersistence: {
get: async () => 0n,
set: async watermark => {
/* save watermark */
},
},
},
algorand.client.algod,
algorand.client.indexer,
);
// Set up subscription(s)
subscriber.on('filter1', async transaction => {
// ...
});
// Set up error handling
subscriber.onError(e => {
// ...
});
// Either: Start the subscriber (if in long-running process)
subscriber.start();
// OR: Poll the subscriber (if in cron job / periodic lambda)
subscriber.pollOnce();

Real-time Subscriptions

Subscribe to transactions at the tip of the chain with low-latency processing.

Indexing & Catchup

Build indexes from the beginning of the chain with fast indexer catchup.

ARC-28 Events

Subscribe to and process ARC-28 events from smart contract calls.

Resilient Watermarking

Persist watermarks for reliable at-least-once delivery across outages.