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

@keychain-pay/onramp

v1.0.1

Published

Keychain Onramp SDK - Bank to USDC in minutes

Downloads

219

Readme

Keychain Onramp SDK

Bank to USDC in minutes. Let your users buy USDC directly from their bank account.

Features

  • Simple Integration - Just a few lines of code
  • Bank Linking - Plaid-powered bank verification
  • Instant Settlement - Optional instant settlement for amounts ≤$50
  • Same-Day ACH - Funds settle same business day

Installation

npm install keychain-pay/onramp

Quick Start

1. Backend: Create a Session

Use your secret key (never expose this on the frontend):

import { KeychainOnramp } from 'keychain-pay/onramp';

const onramp = new KeychainOnramp('sk_live_xxx');

// Create a session
const session = await onramp.sessions.create({
  destinationAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f...',
  amount: 10000, // $100 in cents (optional)
  successUrl: 'https://yoursite.com/success',
  cancelUrl: 'https://yoursite.com/cancel',
  webhookUrl: 'https://yoursite.com/webhooks/keychain',
});

// Return session URL to your frontend
res.json({ url: session.url, sessionId: session.id });

2. Frontend: Open the Onramp

Option A: Simple Redirect (no SDK needed)

// Redirect to the onramp
window.location.href = session.url;

Option B: Modal/Popup with Callbacks

<script src="https://js.trykeychain.com/onramp.js"></script>
<script>
  // Open as modal
  KeychainOnramp.open('sess_xxx', {
    mode: 'modal', // 'redirect' | 'popup' | 'modal'
    onSuccess: (session) => {
      console.log('Success!', session);
    },
    onCancel: () => {
      console.log('User cancelled');
    },
  });
</script>

Option C: React/Next.js

import { open } from 'keychain-pay/onramp/client';

function BuyButton({ sessionId }) {
  return (
    <button onClick={() => open(sessionId, { mode: 'modal' })}>
      Buy USDC
    </button>
  );
}

API Reference

Backend SDK

KeychainOnramp(secretKey, options?)

Create a new Onramp client.

const onramp = new KeychainOnramp('sk_live_xxx', {
  baseUrl: 'https://developer-api.trykeychain.com', // optional
});

onramp.sessions.create(params)

Create a new onramp session.

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | destinationAddress | string | Yes | Wallet address to receive USDC | | destinationChain | string | No | 'solana' (default), 'ethereum', 'polygon', 'base' | | amount | number | No | Pre-filled amount in cents | | successUrl | string | No | Redirect URL on success | | cancelUrl | string | No | Redirect URL on cancel | | webhookUrl | string | No | Webhook URL for notifications | | referenceId | string | No | Your reference ID | | metadata | object | No | Custom key-value pairs |

Returns:

{
  id: 'sess_abc123...',
  url: 'https://checkout.trykeychain.com/buy-usdc?session_id=sess_abc123',
  amount: 10000,
  destinationAddress: '0x...',
  destinationChain: 'solana',
  status: 'pending',
  testMode: false,
  expiresAt: '2024-01-01T00:00:00.000Z',
}

onramp.sessions.retrieve(sessionId)

Retrieve an existing session.

const session = await onramp.sessions.retrieve('sess_abc123');
console.log(session.status); // 'pending' | 'completed' | 'expired'

Frontend SDK

KeychainOnramp.open(sessionId, options?)

Open the onramp flow.

| Option | Type | Default | Description | |--------|------|---------|-------------| | mode | string | 'redirect' | 'redirect', 'popup', or 'modal' | | onSuccess | function | - | Called on successful completion | | onCancel | function | - | Called when user cancels | | onError | function | - | Called on error |

KeychainOnramp.close()

Close the modal (if open).

KeychainOnramp.getUrl(sessionId)

Get the onramp URL for manual navigation.

Webhooks

When a session completes, we'll send a POST request to your webhookUrl:

{
  "type": "onramp.session.completed",
  "id": "evt_xxx",
  "created": "2024-01-01T00:00:00.000Z",
  "data": {
    "session": {
      "id": "sess_xxx",
      "status": "completed",
      "destinationAddress": "0x...",
      "depositedAmount": 10000,
      "instantSettlement": true,
      "transactionHash": "5eykt4...",
      "completedAt": "2024-01-01T00:00:00.000Z"
    }
  }
}

Test Mode

Use test keys (sk_test_xxx) during development:

const onramp = new KeychainOnramp('sk_test_xxx');

Test mode sessions simulate the full flow without real bank transfers.

Support