Registry / database / warp-contracts-postgres

warp-contracts-postgres

JSON →
library1.1.4jsnpmunverified

PostgreSQL-based state cache for Warp SDK's SmartWeave contracts. Current stable version is 1.1.4. Designed to provide persistent state caching for the Warp Contracts SDK, using PostgreSQL as the backend. Key differentiators: implements the StateSortKeyCache interface, supports efficient state sorting and retrieval, and is intended for production deployments requiring durable state storage. The package is part of the Warp ecosystem and requires warp-contracts >=1.4.19. It ships TypeScript type definitions.

npm install warp-contracts-postgres
INSTALL
IMPORT
SIG · WARP-CONTRACTS-POS
W
warp-contracts-postgres
databasejavascriptv1.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PostgresContractCache
import { PostgresContractCache } from 'warp-contracts-postgres'
const { PostgresContractCache } = require('warp-contracts-postgres');
ESM-only; requires Node >=16.5 with 'type':'module' or .mjs extension.
PostgresContractCache (type imports)
import type { PostgresContractCache } from 'warp-contracts-postgres'
import { PostgresContractCache } from 'warp-contracts-postgres'; when only using as type
If only using the class as a type, use import type to avoid runtime errors if optional peer dep missing.
PostgresCacheOptions
import { PostgresCacheOptions } from 'warp-contracts-postgres'
import PostgresCacheOptions from 'warp-contracts-postgres';
PostgresCacheOptions is a named export, not default.

Connect to Postgres, initialize cache, and integrate with Warp SDK.

import { PostgresContractCache } from 'warp-contracts-postgres'; import { Client } from 'pg'; const dbClient = new Client({ connectionString: process.env.DATABASE_URL ?? 'postgresql://localhost:5432/warp' }); await dbClient.connect(); const cache = new PostgresContractCache(dbClient); await cache.init(); // creates tables if not exists // use with Warp SDK import { WarpFactory } from 'warp-contracts'; const warp = WarpFactory.forMainnet({ db: cache });
Debug
Known issues
gotchaThe init() method creates tables (contract_cache, state_sort_key_cache) and may fail if schema already exists incorrectly.
fix
Ensure you have proper database migration handling; do not call init() on every app start if tables already exist.
affects: >=1.0.0
gotchaThe PostgresContractCache is ESM-only. Using require() will fail unless transpilation is configured.
fix
Use import syntax or enable ESM interoperability (e.g., dynamic import).
affects: >=1.0.0
gotchaRequires a running PostgreSQL instance with connection string provided.
fix
Ensure DATABASE_URL environment variable is set or provide connection config directly.
affects: >=1.0.0
breakingVersion 1.0.0 switched from callback-based to async/await API. Old code using callbacks will break.
fix
Update to use async/await with init() and other methods.
affects: 1.0.0
Errors
Common errors & fixes
Cannot find module 'warp-contracts-postgres'
Package not installed or ESM not configured correctly
fix
Run 'npm install warp-contracts-postgres' and ensure package.json has 'type':'module' or use .mjs extension.
Error: connect ECONNREFUSED ::1:5432
PostgreSQL not running or connection string is wrong
fix
Start PostgreSQL or correct DATABASE_URL (use localhost:5432 if IPv6 is disabled).
TypeError: client.query is not a function
Passed wrong client object (e.g., pg.Pool instead of pg.Client)
fix
Use a pg.Client instance: const client = new pg.Client(connectionString);
Upgrade
Version history
1.1.4latest on npm
Audit
Dependencies
warp-contractsrequiredPeer dependency: provides the Warp SDK and StateSortKeyCache interface
Agent activity
35 hits · last 30 days
node
32
Meta
1
Resources
warp-contracts-postgres — npm install warp-contracts-postgres · libregistry