@txfence/storage-pg
PostgreSQL ReceiptStore implementation for production multi-process deployments.
Installation
npm install @txfence/storage-pg pgSetup
import { createPgReceiptStore, initSchema } from '@txfence/storage-pg'
import { Pool } from 'pg'
const pool = new Pool({ connectionString: process.env.DATABASE_URL })
await initSchema(pool)
const receiptStore = createPgReceiptStore(pool)initSchema is idempotent — safe to call on every startup.
Options
createPgReceiptStore(pool, { tableName: 'txfence_receipts' })tableName defaults to txfence_receipts.
Querying
const receipts = await receiptStore.list({ chain: 'ethereum', from: 21000000 })Indexes on chain and confirmed_at_block for efficient filtering.
Notes
txfence does not manage the connection lifecycle — inject your own pg.Pool. Upserts use ON CONFLICT DO UPDATE for idempotency. Full bigint serialization via string conversion for JSONB storage.
Last updated on