Search…
Withdraw of funds
As a dApp or web app that wants to integrate the Public Mint Widget to enable your users to withdraw funds from a given address (yours or theirs), you can easily embed the widget onto your application with a simple javascript code.
Public Mint's Widget is made available through a SDK that needs to be included on your application.

Initialisation

Initialise the SDK by creating an instance of the PmintWidgetSdk class:
1
import PmintWidgetSdk from '@publicmint/widget-sdk';
2
3
const pmint = new PmintWidgetSdk();
Copied!

Withdraw widget

To show the withdraw widget, call the renderWithdraw method. This method returns a promise that resolves with either completed or canceled.
1
import { withdraw } from '@publicmint/widget-sdk';
2
import PublicMintWeb3 from '@publicmint/publicmint-web3';
3
4
const status = await pmint.renderWithdraw({
5
blockchain: 'publicmint',
6
burn: options => {
7
// Perform the blockchain operation.
8
// When using the public mint blockchain use our `withdraw` utility:
9
const web3 = new PublicMintWeb3();
10
return withdraw(web3, { ...options, privateKey });
11
},
12
locale: 'en',
13
originAddress: address
14
})
Copied!
The renderWithdraw method requires that you pass the information necessary for the widget to know what to show the user:
    blockchain - the target blockchain for the funds. At this stage only we only support publicmint as the target blockchain.
    originAddress - the address from where the funds will be taken. This address can be yours (ex: a liquidity pool) or your customer's address.
    locale - The localization to be used by the widget.
    burn - a callback function to be used sign and submit the operation to the blockchain. It is at this stage that the address private key is need.

Example

Last modified 4mo ago