@peltier/core
v0.2.0
Published
Peltier protocol core — payment flows, EIP-712 signing, stealth derivation, API client, webhook + x402 primitives. React-free; runs in Node 18+, Bun, Deno, edge, browsers, and React Native.
Readme
@peltier/core
Any ERC-20 on any chain → USDC at your destination. This is the React-free protocol core every other Peltier package builds on: payment flow primitives, a fetch-based API client, EIP-712 signing, stealth-address derivation, webhook verification, and x402 wire types.
No React, no DOM, no node: imports — runs in Node 18+, Bun, Deno, edge runtimes,
browsers, and React Native.
npm install @peltier/core viemWhich package do I want?
| You are building | Install |
|---|---|
| A backend (402 gate, webhooks, subscriptions) | @peltier/node — re-exports all of core |
| A React web app | @peltier/react — widgets + hooks |
| A React Native app | @peltier/react-native — RN widgets + hooks |
| Anything else (CLI, agent, worker, custom UI) | this package |
Quickstart
import { createPeltierClient } from '@peltier/core'
const peltier = createPeltierClient({
apiUrl: 'https://api.peltier.dev',
publishableKey: 'pk_live_…', // or secretKey: 'sk_live_…' on a server
})
// Register a deposit session, then watch it settle
const session = await peltier.registerSession({ /* … */ })
peltier.watchSession(session.id, (update) => {
console.log(update.status)
})Every session / merchant / subscription method is bound to the one config object.
The free functions (registerSession, watchSession, getQuote, createPaymentSession, …)
remain exported as the low-level escape hatch — same behavior, explicit apiUrl argument.
What's inside
- Flow primitives — deposit, request/receive (
createRequestSession,buildOpenTokenIntent), send, and stealth flows;createBurnerWalletfor ephemeral depositor keys. - API client —
createPeltierClientplus free functions:registerSession,commitIntent,getQuote,fetchBalances,createPaymentSession,watchSession(SSE with automatic reconnect + polling fallback), and more. - EIP-712 signing —
signIntent,signRefund,signStandingRefund, typed-data builders (intentTypedData,refundTypedData) that byte-match the on-chainPeltierDelegatecontracts. - Stealth addresses — meta-address derivation, announcements, and withdrawal
helpers for EVM and Solana (
StealthMetaAddress,StealthKeys). - Webhooks —
verifyWebhookSignature(payload, signature, secret)(async) andverifyWebhookSignatureDetailedreturning{ ok, reason }. - x402 —
parse402and theX402Body/X402Acceptswire types for agent-side handling of HTTP 402 payment challenges. - Subscriptions —
subscriptionTypedData,subscriptionId, and the typed REST surface for recurring on-chain charges. - Test mode — Stripe-style key parity:
pk_test_/sk_test_keys route to testnets automatically (keyMode,chainsForMode,TESTNET_CHAINS).
Error handling
Every API call throws a typed PeltierApiError instead of a bare Error:
import { isPeltierApiError } from '@peltier/core'
try {
await peltier.getSession(id)
} catch (err) {
if (isPeltierApiError(err)) {
// err.status, err.endpoint, err.kind: 'http' | 'network' | 'timeout' | 'parse'
}
}Every call also accepts trailing opts?: { timeoutMs?, signal?, fetch? } — default
timeout 30 s.
Supported chains
Mainnet: Ethereum, Arbitrum, Base, Optimism, Polygon, Monad, HyperEVM
(destination-only), and Solana (deposit source + settlement destination). Each EVM
chain has a testnet counterpart reached automatically with pk_test_ / sk_test_
keys. Full matrix: peltier.dev/docs/supported-chains.
Docs
Full documentation lives at peltier.dev/docs.
License
MIT
