npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cadence-sdk

v1.0.2

Published

Merchant SDK for Cadence — checkout URLs, webhook verification, USDC helpers

Readme

cadence-sdk

Server-side utility package for merchants integrating with Cadence.

This SDK does not interact with the blockchain or manage wallets. It provides typed, zero-dependency helpers for the things merchants need on their backend: building checkout URLs, verifying webhook signatures, and working with USDC amounts/intervals.

Install

npm install cadence-sdk

Quick Start

Build a checkout URL

import { createCheckoutUrl } from 'cadence-sdk'

const url = createCheckoutUrl({
  merchant: '0x690C65EB2e2dd321ACe41a9865Aea3fAa98be2A5',
  amount: 9.99,
  interval: 'monthly',
  metadataUrl: 'https://mysite.com/plans/pro.json',
  successUrl: 'https://mysite.com/success',
  cancelUrl: 'https://mysite.com/cancel',
  spendingCap: 119.88,
})

Verify webhooks

import { verifyWebhook } from 'cadence-sdk'

const event = verifyWebhook(rawBody, req.headers['x-Cadence-signature'], secret)

if (event.type === 'charge.succeeded') {
  console.log(event.data.amount)      // TypeScript knows this exists
  console.log(event.data.protocolFee)
  console.log(event.data.txHash)
}

API

Checkout

| Function | Description | |----------|-------------| | createCheckoutUrl(options) | Build a checkout URL with validation | | parseSuccessRedirect(queryString) | Parse policyId and txHash from success redirect | | resolveInterval(preset \| seconds) | Convert interval preset to seconds |

Webhooks

| Function | Description | |----------|-------------| | verifyWebhook(body, signature, secret) | Verify + parse webhook (discriminated union) | | verifySignature(payload, signature, secret) | Verify HMAC-SHA256 signature only | | signPayload(payload, secret) | Sign a payload (for testing) |

Amounts

| Function | Description | |----------|-------------| | formatUSDC(rawAmount) | "9990000""9.99" | | parseUSDC(amount) | 9.99"9990000" | | calculateFeeBreakdown(rawAmount) | Total, merchant receives, protocol fee | | formatInterval(seconds) | 2592000"monthly" |

Metadata

| Function | Description | |----------|-------------| | validateMetadata(data) | Validate JSON against metadata schema | | createMetadata(options) | Create a valid metadata object |

Constants

| Export | Value | |--------|-------| | intervals.minute | 60 | | intervals.weekly | 604_800 | | intervals.biweekly | 1_209_600 | | intervals.monthly | 2_592_000 | | intervals.quarterly | 7_776_000 | | intervals.yearly | 31_536_000 | | intervals.custom(count, unit) | Custom interval — units: 'minutes', 'hours', 'days', 'months', 'years' | | PROTOCOL_FEE_BPS | 250 (2.5%) | | USDC_DECIMALS | 6 | | MIN_INTERVAL | 60 (1 minute) | | MAX_INTERVAL | 31_536_000 (365 days) | | MAX_RETRIES | 3 | | DEFAULT_CHECKOUT_BASE_URL | 'https://Cadenceprotocol.com' | | chains | Chain configs (Polygon Amoy, Arbitrum Sepolia, Arc Testnet) |

Error Classes

| Class | Code | |-------|------| | CadenceError | Base error with code property | | CadenceWebhookError | 'WEBHOOK_VERIFICATION_FAILED' | | CadenceCheckoutError | 'INVALID_CHECKOUT_PARAMS' | | CadenceMetadataError | 'INVALID_METADATA' |

Webhook Event Types

All events share { type, timestamp, data: { policyId, chainId, payer, merchant } } plus event-specific fields:

| Event | Extra Fields | |-------|-------------| | charge.succeeded | amount, protocolFee, txHash | | charge.failed | reason | | policy.created | chargeAmount, interval, spendingCap, metadataUrl | | policy.revoked | endTime | | policy.cancelled_by_failure | consecutiveFailures, endTime |

Exported Types

CheckoutOptions, SuccessRedirect, IntervalPreset, WebhookEvent, WebhookEventType, ChargeSucceededEvent, ChargeFailedEvent, PolicyCreatedEvent, PolicyRevokedEvent, PolicyCancelledByFailureEvent, CheckoutMetadata, FeeBreakdown, MetadataValidationResult, ChainConfig

Zero Dependencies

This package has zero runtime dependencies. It only uses Node.js built-in crypto.

License

Apache-2.0