For the complete documentation index, see llms.txt. This page is also available as Markdown.

Web Sdk

Onramp Web SDK

A TypeScript/JavaScript SDK for integrating Onramp's crypto purchase widget into your web application.

Installation

Install the SDK using npm:

npm install @onramp.money/onramp-web-sdk

Or using yarn:

yarn add @onramp.money/onramp-web-sdk

Quick Start

1. Import the SDK

ES6/TypeScript:

import { OnrampWebSDK } from '@onramp.money/onramp-web-sdk';

CommonJS:

const { OnrampWebSDK } = require('@onramp.money/onramp-web-sdk');

Browser (UMD):

<script src="node_modules/@onramp.money/onramp-web-sdk/dist/onramp-web-sdk.umd.js"></script>

2. Initialize the SDK

3. Show the Widget

4. Handle Events (Optional)

5. Close the Widget

Usage Examples

Basic Overlay Mode

Embedded Mode

Custom Theming

widgetUrl

You can pass the kycUrl you get from our api into the sdk to initialise it as a kyc sdk

Configuration Options

Parameter
Type
Required
Description

appId

number

✅

Your application ID from Onramp dashboard

walletAddress

string

❌

User's wallet address

coinCode

string

❌

Cryptocurrency code (e.g., "USDT", "ETH")

network

string

❌

Blockchain network (e.g., "polygon", "ethereum")

fiatAmount

number

❌

Pre-filled fiat amount

coinAmount

number

❌

Pre-filled crypto amount

paymentMethod

number

❌

Preferred payment method ID

flowType

number

❌

1: Buy, 2: Sell, 3: Checkout, 4: Swap

containerId

string

❌

DOM element ID for embedded mode (e.g., "#container")

theme

object

❌

Custom theme configuration

sandbox

boolean

❌

Use sandbox environment for testing

lang

string

❌

Language code (e.g., "en", "es")

phoneNumber

string

❌

Pre-filled phone number

redirectUrl

string

❌

Redirect URL after completion

widgetUrl

string

❌

Kyc url containing kybData

Flow Types

  • 1 (Buy/Onramp): Purchase cryptocurrency with fiat

  • 2 (Sell/Offramp): Sell cryptocurrency for fiat

  • 3 (Checkout): NFT/asset purchase flow

  • 4 (Swap): Cryptocurrency swap

Event Types

Transaction Events (TX_EVENTS)

  • ONRAMP_WIDGET_TX_INIT

  • ONRAMP_WIDGET_TX_FINDING

  • ONRAMP_WIDGET_TX_SELLING

  • ONRAMP_WIDGET_TX_PURCHASING

  • ONRAMP_WIDGET_TX_SENDING

  • ONRAMP_WIDGET_TX_SENT

  • ONRAMP_WIDGET_TX_COMPLETED

Widget Events (WIDGET_EVENTS)

  • ONRAMP_WIDGET_READY

  • ONRAMP_WIDGET_CLOSE_REQUEST_CONFIRMED

  • ONRAMP_WIDGET_FAILED

  • ONRAMP_WIDGET_CONTENT_COPIED

  • ONRAMP_WIDGET_LOGIN_SUCCESS

  • ONRAMP_WIDGET_NAVIGATION

KYC Events (KYC_EVENTS)

  • ONRAMP_KYC_READY

  • ONRAMP_KYC_PENDING

  • ONRAMP_KYC_ERROR

  • ONRAMP_KYC_REJECTED

  • ONRAMP_KYC_CLOSE

Methods

show()

Displays the Onramp widget.

close()

Closes the Onramp widget.

on(eventType, callback)

Registers event listeners.

Error Handling

Complete Example

Support

For questions and support:

Last updated