LogoLogo
  • Introduction
  • Core Concepts
  • Partner setup
  • Tutorials [WIP]
    • Create Identities
    • Create a Blockchain Address
    • Payout Service
  • Public Mint Widget
    • Getting started
    • Embed Widget
      • Deposit of funds
      • Withdraw of funds
  • Public Mint API
    • Getting started
    • Creating identities
    • Connecting to the blockchain
      • Running your own client node
    • Executing Transactions
      • Depositing
      • Wallet Transactions
      • Withdrawing
    • Sandbox
    • API Reference
      • Identities
      • Operations
      • Transfer Methods
      • Transactions
      • Withdrawals (deprecated)
      • Verifications
      • Identity Relations
      • Documents
      • Deposits (deprecated)
      • Authentication
      • Pagination
      • Errors
      • Core Resources
    • Webhooks
  • Public Mint Blockchain
    • Getting started
    • Transacting
    • Configuring Metamask for the Public Mint blockchain
    • Interoperability [WIP]
  • Other Information
    • Public Mint Wallet
    • Users and Accounts
Powered by GitBook
On this page
  • Initialisation
  • Withdraw widget
  • Example

Was this helpful?

  1. Public Mint Widget
  2. Embed Widget

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:

import PmintWidgetSdk from '@publicmint/widget-sdk';

const pmint = new PmintWidgetSdk();

Withdraw widget

To show the withdraw widget, call the renderWithdraw method. This method returns a promise that resolves with either completed or canceled.

import { withdraw } from '@publicmint/widget-sdk';
import PublicMintWeb3 from '@publicmint/publicmint-web3';

const status = await pmint.renderWithdraw({
  blockchain: 'publicmint',
  burn: options => {
    // Perform the blockchain operation.
    // When using the public mint blockchain use our `withdraw` utility:
    const web3 = new PublicMintWeb3();
    return withdraw(web3, { ...options, privateKey });
  },
  locale: 'en',
  originAddress: address
})

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

PreviousDeposit of fundsNextGetting started

Last updated 3 years ago

Was this helpful?