Start by creating a new directory for your project if you haven't already:
mkdir my-web3-project
cd my-web3-project
Initialize a new Node.js project:
npm init -y
Install the Required Dependencies
Additionally, we'll use the dotenv package to manage environment variables.
Install the required dependencies:
npm install @oneramp/sdk ethers dotenv
Create a .env File
Create a .env file in your project's root directory to store sensitive information like your private key and OneRamp credentials. Replace the values with your actual credentials:
Before you offramp your users with real money, it's advisable to show them a price quote of the amount they’re going to receive. Fortunately, oneramp has a .quote() returns a specific quote amount that the user will receive in their wallet.
Run the scrit using:
node oneramp-integration.js
Output:
====================================
{
recives: 4.9,
estimated_fee: 0.1,
amount: 5,
asset: 'usdt',
memo: 'Prices may vary with local service providers'
}
====================================
This output represents the quote for offramping 5 USDT to mobile money.
Now that we've got the quote too, we can go ahead and offramp the user to mobile money.