Comment on page


Enable Token Purchases via Fiat Currency
ORE ID Developers can enable users to purchase tokens directly from their dApp using fiat currency by leveraging Onramper. This feature is available to all ORE ID users and can be accessed directly via the ORE ID API or the OREID-js Javascript package.

Launching the ORE ID Onramper Flow

Our recommended method for activating the Onramper flow is to leverage the OREID's Javascript SDK. This includes both the OREID-js and oreid-webpopup packages. You may install both of these using your package manager of choice.
yarn add oreid-js oreid-webpopup
npm install oreid-js oreid-webpopup

Initialize OREID

Before we can call the popup, we'll need to initialize the OREID connection.
import { OreId } from "oreid-js";
import { WebPopup } from "oreid-webpopup";
const oreId = new OreId({ appId, plugins:{ popup: WebPopup() }});
// oreid is ready

User Login

Next, the user will need to be logged into their OREID account. This can also be done using the OREID Web popup.
const onClick = () => {
oreId.popup.auth({ provider: 'google' })
.then(data => {console.log(data)})
.catch(error => {console.log(error.message)});
<button onClick="onClick()">Auth</button>

Activate Web Popup

Finally, you can activate Onramper using the buy function of the popup. Here, you'll also be able to enter parameters that will dictate which currencies and networks are available to the user.
const onClick = () => {
const userChainAccounts = oreId.auth.user.data.chainAccounts;
// Select the currency account that you would like to default to in the OnRamper flow
// The user can select a different account using a dropdown menu if they wish
const ethAccount = userChainAccounts.find(ca => ca.chainNetwork === 'eth_main')
// These are the properties required to launch the popup
const onramperBuy = {
chainAccount: ethAccount.chainAccount,
chainNetwork: ethAccount.chainNetwork,
// Launch the OnRamper flow
oreId.popup.buy({ onramperBuy })
.catch( onError );
<button onClick="onClick()">Buy Crypto</button>


The params to use the buy function of OREID-JS are as follows:
The blockchain account that will receive the purchased tokens. This provided account must belong to the user that is currently logged in. If it doesn't, the popup will fail to active and the function will return an error.
This is a required field.
The blockchain network that the tokens will be purchased on. The available options can be found on the Chain Mappings page.
This is a required field.
The selection must be a network that the app currently has access to or the popup will fail to activate. If additional access rights are needed, please contact your account manager.
An optional array of token symbols that the user can select from. If this is not provided, the user will be able to select from all supported tokens.
The allowed values for limitToSymbols are NOT the same as those in the onRamper docs - they are mapped. These mappings can be found on the Chain Mappings page.
If the transaction is properly configured, you should see the Onramper flow initiate with the desired network and currency automatically selected.
Do not complete the buy action if you are running on a test chain. The purchase will be mapped to the main chain. You will not be able to recover the tokens

Onramper Tokens

The Onramper integration supports the purchase of the following tokens: