Funding via wire/ACH
Add programmable onramps and offramps to your app
Privy enables programmable stablecoin onramping and offramping by natively integrating third party providers directly within Privy’s API. This recipe details how your app can use Privy to provide a seamless, customizable fiat/crypto conversion experience for your users. Privy currently supports:
Using Privy’s APIs, you can:
- Link Privy’s user account with an onramp provider user account and bank accounts
- Onramp (convert fiat to crypto)
- Offramp (convert crypto to fiat)
- Use multiple onramp providers in your app, e.g. in order to serve users in different regions
Setup
Get API keys from the onramp provider
First, register with your onramp provider and get API keys for your onramp provider account.
Configure your app to use the onramp provider
Register your onramp provider API keys with Privy by making a request to the /v1/apps/[app_id]/fiat
endpoint.
Register a new user for onramp or offramp
When a user is onramping or offramping via the provider for the first time, they must agree to their terms of service, as well as go through the KYC process.
Provide a terms of service agreement to the user
First, the user must agree to the onramp provider’s terms of service.
You can request a new terms of service url for a user via the tos
endpoint on the user resources.
Then, add the query param redirect_uri
to the url, so that after the user goes to that link and signs the terms of service, the user is redirected to your app. Upon redirect, a signed_agreement_id
parameter will in the url, which you will use for the next KYC step.
Submit the user’s KYC information
In order to onramp or offramp, the user must first be KYC’d. You can check their KYC status via the kyc
endpoint on the user resource.
If the user is not KYC’d yet, gather and submit their KYC information by making a POST
request to the same endpoint.
Note: After submission, the KYC process takes about 1-2 minutes to undergo review. Sometimes, a manual review is required, which can take longer (a few hours).
Onramp funds
This assumes that all the above steps have been completed.
Trigger the onramp flow
Once the user is KYC’d, you can trigger the onramp flow by making a POST
request to the /fiat/onramp
endpoint.
This will return deposit instructions for the user to complete, since they will need to send fiat funds to the onramp provider in order to receive stableocins in their wallet.
[For bank transfer] Follow bank deposit instructions
If the onramp method is a bank transfer, the user will need to follow the specific instructions to send a bank deposit with the specified deposit message. If these instructions are not followed correctly, the onramp will fail.
Offramp
This assumes that that the Terms of Service and KYC process have been completed for the user.
Register a fiat account to offramp to
In order for the onramp provider to offramp and send fiat funds to the user, the user must first register a fiat account (e.g. bank account) with them.
You can do so by making a POST
request to the /fiat/accounts
endpoint.
Trigger the offramp flow
Once the user has a fiat account registered, you can trigger the offramp flow by making a POST
request to the /fiat/offramp
endpoint.
This will return deposit instructions for the user to complete, since they will need to send their stablecoins to the onramp provider’s on-chain address in order to receive fiat funds in their account.
Follow on-chain deposit instructions
Use Privy to send stablecoins from the user’s wallet to the onramp provider’s on-chain address. As an example of how to do this, see the Send USDC recipe.