On-Off Ramp

In this section, you'll learn how to use Cashramp to on-off ramp stablecoins to/from a DApp/self-custodial wallet.

Supported stablecoins

StablecoinNetworkRamp availableFees

CUSD

CELO

On-ramp, Off-ramp

$0.01

USDC

OP

Off-ramp

$0.3

USDC

BASE

Off-ramp

$0.3

USDC

MATIC

Off-ramp

$0.3

USDC

SOL

Off-ramp

$0.5

Getting started

An API key is all you need to get started with onchain on-off ramping. You can create yours by following the authentication steps.

The on-off ramp flow is accessible via a URL that can be customized to your specific use case with query parameters.

Base URL

  • Staging: https://staging.useaccrue.com/hosted/ramp

  • Production: https://useaccrue.com/hosted/ramp

URL Query Parameters

  • key (required): Your public key.

  • paymentType (required): Either deposit or withdrawal

  • address (optional): The wallet address you want to deposit into or withdraw from. If this is not provided, we'll attempt to detect the address from the injected wallet context window.ethereum

  • coin (required): The stablecoin you want to deposit/withdraw

  • network (required): The network you want to deposit/withdraw via

  • amount (optional): The quantity of the stablecoin you want to deposit/withdraw

  • reference (optional): Your unique reference

  • redirectUrl (optional): The URL you want us to redirect your customer to after the transaction is completed.

  • currency (optional): The ISO 4217 currency code

  • phone (optional): The phone number of the customer

  • hideAddress (optional): Set to true if you want to hide the customer's wallet address in the payment flow

  • isWalletContext (optional): Set to false if you want to explicitly ignore window.ethereum in favour of your custom crypto deposit flow. By default, it's true

Example URL
https://useaccrue.com/hosted/ramp?key=CSHRMP-PUBK_mO86nN3ye84hIso&paymentType=deposit&coin=CUSD&network=CELO&amount=10&reference=test_reference

Custom crypto deposit flow

If you're using the Onchain Ramp webpage/widget in a browser with a window.ethereum object available, during the offramp flow, we will automatically initiate a transaction signing prompt for any injected wallet (Rainbow, Metamask, etc).

However, if window.ethereum isn't available, we send a message event that you can listen for and spin up your customized experience for sending in crypto from a user's wallet address to the Cashramp Escrow Address.

window.addEventListener("message", (message) => {
    if (message.origin === "https://useaccrue.com") {
        const { event, payload } = message.data;
        if (event === "crypto.requested") {
            const amountUsd = parseFloat(payload.amountCents) / 100;
            const destinationAddress = payload.destinationAddress;
            const paymentRequest = payload.paymentRequest;
            
            // Here's where you add your custom experience for sending the *exact* USD amount to Cashramp's Escrow Address (destinationAddress)
            
            // You can request transaction confirmation here by providing the payment request global ID provided above as `paymentRequest`
        }
    }
});

Confirm transaction

After successfully initiating your crypto transfer to the wallet address we provided to you, you can poll our servers to request transaction confirmation with the mutation below.

We recommend that your polling frequency be proportionate to your blockchain's block time. For example, CELO & Optimism can be 10s, and Ethereum can be 1min.

If the transaction is confirmed, we'll do the following:

  • Update the payment request status from pending_funding to created. We will also send a webhook notification about the update.

  • Automatically email your user a payment link that allows them to withdraw the fiat equivalent of their USD stablecoin payment.

confirmTransaction.gql
mutation {
      confirmTransaction(paymentRequest: "VHlwZXM6OkNhc2hyYW1wOjpBUEk6Ok1lcmN6YW50UGF5bWVudFJlcXVlc3QtZjVkZDdhYWEtZDI1Yy00YTZmLTkwODMtNzk1NjdkOTNjNmM4", transactionHash: "0x4321897b3c4495a314d081dbcf2cb5310b19834bda124f5ad03e07464b1add73")
}

Arguments

  • paymentRequest: The global ID of the payment request you want to confirm

  • transactionHash: The transaction hash for the crypto transfer you initiated

Last updated