Mooni
Search…
Frontend integration
Integrate Mooni into your app
Mooni is the off-ramping solution for the DeFi ecosystem, which can enable users of your dApp to cash out the cryptocurrencies they earn directly into their bank account.
Our widget SDK is a super simple solution to integrate Mooni into your already existing application. The widget can either appear as a modal on top of an app, or included inside an HTML element. If the hosting app already has a connected user with web3, this wallet can be forwarded to the widget.

📺 Example integration

🎁 Quick start

Install
yarn add @mooni/widget
Start widget
1
// Import package
2
import MooniWidget from '@mooni/widget';
3
4
// Instanciate the widget
5
const mooni = new MooniWidget();
6
7
// Open the widget as a modal when you want it
8
mooni.open();
Copied!
That’s it 🥂 !

🎛 API Reference

MooniWidget

1
constructor(opts: MooniWidgetOptions)
Copied!
Methods
Open widget
1
open(): void
Copied!
Opens Mooni as a widget.
Set Ethereum provider
1
setEthereum(ethereum?: EthereumProvider): void
Copied!
Set an Ethereum provider. Call this method when your users log in with their wallet. They will become automatically logged in Mooni.

MooniWidgetOptions

1
containerElement?: HTMLElement
Copied!
Include Mooni inside of an HTML element on your website if you don’t want to use modal mode.
1
ethereum?: EthereumProvider
Copied!
A standard JSON-RPC provider. This is useful if the hosting app already authenticated the web3 wallet of the user, so he doesn’t have to login again on Mooni.
1
token?: string
Copied!
Automatically select a token to sell in Mooni. Must be an ERC20 contract address. Default is ETH.
1
referralId?: string
Copied!
Sets a referral account. All orders passed with this referral ID through the widget will share profit. You can find your referral ID on your Account page.

Additional information

Import on different module systems

    ES6
import MooniWidget from '@mooni/widget';
    CommonJS
const MooniWidget = require('@mooni/widget');
    UMD
1
/* available as MooniWidget */
2
</script> ```
3
## 💻 Development
4
5
``` # Install dependencies yarn
6
# Build package yarn build
7
# Publish package npm publish ```
Copied!
Last modified 7mo ago