πŸ§‘β€πŸ’» OnRamp

Your users can easily purchase cryptocurrency directly through the on-ramp feature.


onRamp()

By using theΒ onRamp()Β method of Face Wallet SDK, you can open MoonPay on-ramp widget. When using this method, you must provide an array of Blockchain values as an argument, and MoonPay on-ramp widget will display the available cryptocurrencies for that blockchains.

import { Face, Network, Blockchain } from '@haechi-labs/face-sdk';

const face = new Face({
  network: Network.GOELRI, 
  apiKey: 'YOUR_DAPP_API_KEY'
});

// Login required

await face.wallet.onRamp([ Blockchain.ETEREUM, Blockchain.POLYGON]);

onRampToken()

The onRampToken()Β method will open the MoonPay widget for the specific cryptocurrency you passed as arguments. To specify a coin, you'll need to provide the coin's blockchain and contract address as arguments. If there is no matching coin among the coins registered in your dapp, you will receive an error with the code 4400. The blockchain and contract address are required arguments.

For the error, see the error page.

πŸ“˜

If you want to choose a platform coin such as ETH or MATIC to buy, pass '0x0' as the contract address.

You can also set the amount of cryptocurrency you want the user to buy. To do this, pass the amount of cryptocurrency as a positive integer as the third argument to this method. The amount is an optional argument.

import { Face, Network, Blockchain } from '@haechi-labs/face-sdk';

const face = new Face({
  network: Network.GOELRI, 
  apiKey: 'YOUR_DAPP_API_KEY'
});

// Login required

await face.wallet.onRampToken(Blockchain.ETEREUM, '0x0', 5);

🚧

The actual value set in MoonPay may also depend on MoonPay policies.