Skip to main content

Generating a URL

Coinbase Pay SDK can generate a URL that is launched by a browser mechanism (for example, a link or button on web, or a webview, or linking on mobile).

This approach is designed for those who want to use the Coinbase Pay functionality by embedding the SDK, but want additional control over how the experience is triggered.

Step 1: Install Coinbase Pay SDK.

Step 2: Integrate Coinbase Pay in your crypto wallet or app.

Step 3: Call the generateOnRampURL method.

Call the generateOnRampURL method

After integrating Coinbase Pay by creating the Coinbase Pay button and implementing initOnRamp, you call the generateOnRampURL method.

generateOnRampURL Example

import { generateOnRampURL } from "@coinbase/cbpay-js";

const onRampURL = generateOnRampURL({
appId: "1dbd2a0b94",
destinationWallets: [
{ address: "0xabcdef", blockchains: ["solana"] }
{ address: "0x123456", assets: ["ETH", "USDC"] }

You can use generated URL to launch a new tab, webview, etc., with either the provided buttons or text.

<a href={onRampURL} target="_blank">Coinbase Pay</a>

Parameters for generateOnRampURL

The following table outlines the parameters supported in the generateOnRampURL function:

appIdYesStringUnique short-string ID provided to partners by the Coinbase Pay team
destinationWalletsYesObjectArray of destinationWallet objects which define blockchain types (blockchains) and destination addresses (address).
Format: {address: string; blockchains?: string[]; assets?: string[]}[]

destinationWallets Parameters

The destination wallet object accepts the following parameters:

addressYesStringDestination address where the purchased tokens will be sent.
blockchainsNoString[]List of blockchains enabled for the associated address. All tokens available per blockchain are displayed to the user. Available blockchains are: ethereum, avalanche-c-chain, solana.
assetsNoString[]List of assets enabled for the associated address. They are appended to the available list of tokens for the user to buy or send.

See Also:

Was this helpful?