Back to IntegrationsREGISTER YOUR WALLETSource → Source →
Automation & Scripting
Herald + Node.js Script
Write standalone Node.js scripts using the Herald SDK for automated notification workflows. Perfect for liquidation bots, governance broadcast scripts, batch airdrops, staking rewards notifications, and bridge transfer alerts — each script is a self-contained example.
Ready to ship?
Start sending zero-PII notifications in minutes.
ZK-SECURE SOLANA NATIVE
Package: @herald-protocol/sdk
Install: npm install @herald-protocol/sdk tsx
View full example on GitHub →Send Liquidation Warning
Standalone script — init SDK, send defi notification, log result.
Node.js Script / Send Liquidation Warning
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Herald } from '@herald-protocol/sdk';
const herald = new Herald({ apiKey: process.env.HERALD_API_KEY!,});
interface LiquidationParams { wallet: string; positionId: string; healthFactor: number; debtAmount: number; asset: string;}
async function sendLiquidationWarning(params: LiquidationParams) { const idempotencyKey = `liquidation_${params.positionId}_${Math.floor(Date.now() / 30000)}`;
const result = await herald.notify({ wallet: params.wallet, subject: `⚠️ Liquidation Warning — Health factor: ${params.healthFactor.toFixed(2)}`, body: [ `Your lending position #${params.positionId} is approaching liquidation.`, ``, `Current health factor: ${params.healthFactor.toFixed(2)}`, `Outstanding debt: ${params.debtAmount} ${params.asset}`, ``, `Action required: Add collateral or repay debt immediately.`, `Threshold: 1.00`, ].join('\n'), category: 'defi', receipt: true, idempotencyKey, });
console.log(`[Liquidation] Sent → ${result.notificationId} (${result.status})`); return result;}
const params: LiquidationParams = { wallet: '7xR4mKp2nQwBvTsYjL8dHcFoEa3ZiXuW', positionId: 'POS-42069', healthFactor: 1.05, debtAmount: 50000, asset: 'SOL',};
sendLiquidationWarning(params).catch(console.error);Webhook Verification
Verify HMAC-SHA256 signature and handle delivery events.
Node.js Script / Webhook Verification
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Herald } from '@herald-protocol/sdk';
async function handleHeraldWebhook( rawBody: string, signatureHeader: string, webhookSecret: string,) { const isValid = await Herald.verifyWebhookSignature( rawBody, signatureHeader, webhookSecret, );
if (!isValid) { console.error('[Webhook] INVALID SIGNATURE — rejecting'); return { status: 401, body: 'Invalid signature' }; }
const payload = JSON.parse(rawBody);
switch (payload.event) { case 'delivery.confirmed': console.log(`[Webhook] ✅ ${payload.notificationId} delivered`); break; case 'delivery.failed': console.error(`[Webhook] ❌ ${payload.notificationId} failed: ${payload.error}`); break; case 'delivery.bounced': console.warn(`[Webhook] ⚠️ ${payload.notificationId} bounced`); break; }
return { status: 200, body: 'ok' };}Common Patterns
Liquidation warning script with idempotency
Governance proposal broadcast
Batch airdrop from CSV wallet list
Staking rewards and yield APY alerts
Start building with Herald
Clone the examples repo, copy the code that fits your stack, and deploy.