Secondary Marketplace Kit

⚙️ How to Install and Setup the Mojito Secondary-marketplace SDK module.

Overview

The Secondary Marketplace SDK is a powerful platform that enables users to purchase Non-Fungible Tokens (NFTs) using cryptocurrency. This SDK offers a range of functionalities to facilitate seamless transactions within the secondary NFT market. This documentation will focus on the key features of the SDK, including the Product Details Page (PDP), making offers, buying now, accepting offers, rejecting offers, listing items, removing listings, editing listings, and canceling offers.

This guide will help you better understand how to use and integrate the Secondary-marketplace SDK into your application.

📘

Note:

For more detailed information, examples and theme customizations, you can refer to the NPM Public repository here.

Prerequisite

Before proceeding with the installation steps, ensure that you have the following prerequisites in place:

  1. Node.js and NPM/Yarn: Make sure you have Node.js installed on your machine, along with either NPM (Node Package Manager) or Yarn. You can download and install Node.js from the official website here.
  2. API URL: Determine the appropriate API URL to use based on your environment.

Installation and Setup

Step 1: Install the Secondary-marketplace Module

Install the Mojito Secondary-marketplace SDK module on your project by using one of the following methods below:

Install using NPM:

  npm install @mojito-inc/secondary-market

Install using Yarn:

  yarn add @mojito-inc/secondary-market

Install via package.json:

"@mojito-inc/secondary-market": "1.0.3-beta.15"

Step 2: Wrap the Provider and Set API URL, Bearer Token and Theme

In your project's root file, follow these steps to wrap the provider and configure the API URL, Bearer token and Theme:

  1. Determine the appropriate API URL based on your environment:

    • For the development environment, set API_URL to https://api-dev.mojito.xyz/query.
    • For the production environment, set API_URL to https://api.mojito.xyz/query.
  2. Wrap the provider using the SecondaryMarketProvider component from the Mojito Secondary-marketplace SDK.

    • Import the SecondaryMarketProvider from @mojito-inc/secondary-market in your JavaScript file.
    • Use the SecondaryMarketProvider component and provide the following props:
      • uri: Set this prop to the determined API_URL based on your environment.
      • token: Pass the obtained JWT token or Auth0 token as the value for this prop. Use the format Bearer <Token>.
import { SecondaryMarketProvider } from "@mojito-inc/secondary-market";
import { ThemeProvider } from '@mui/material/styles';

const client = {
  uri: API_URL,
  token: tokenData ? `Bearer ${ tokenData }` : undefined,
}

<ThemeProvider theme={ theme }>
  <SecondaryMarketProvider clientOptions={ client } theme={ theme }>
    { children }
  </SecondaryMarketProvider>
</ThemeProvider>

Step 3: Integrate Product Details Page (PDP)

To use the Product Details Page feature, follow these steps:

Import the necessary modules from the @mojito-inc/secondary-market package:

import { ProductDetailPage } from "@mojito-inc/secondary-market";

<ProductDetailPage
        config={ configuration }
        Image={ Image }
        walletDetails={ walletDetails }
        onClickDisconnectWallet={ onClickDisconnectWallet }
        onConnectWallet={ onConnectWallet }
        onRefetchBalance={ onRefetchBalance }
        tokenDetails={ tokenDetails } />

Fill in the required parameters for the ProductDetailPage

ParameterTypeRequiredDescription
configurationObjectConfiguration
ImageObjectImage
walletDetailsObjectWalletDetails
tokenDetailsObjectTokenDetails
onClickDisconnectWalletfunction-✅function to handle disconnect wallet
onConnectWalletfunction-✅function to handle connect wallet
onRefetchBalancefunctionfunction to handle refetch balance

Fill in the required parameters for the Configuration

ParameterTypeRequiredDescription
orgIdstringorganisation id
infuraIdstringinfura id to connect wallet
paperClientIdstringpaper client id to connect with email
walletOptionsObjectwalletOptions

Fill in the required parameters for the walletOptions

ParameterTypeRequiredDescription
enableMetamaskbooleanto enable or disable metamask
enableWalletConnectbooleanto enable or disable wallet connect
enableEmailbooleanto enable or disable email connect

Fill in the required parameters for the Image

ParameterTypeRequiredDescription
ethIconstringeth icon in svg, png, jpeg or gif format
metamaskstringmetamask icon in svg, png, jpeg or gif format
walletConnectstringwallet connect icon in svg, png, jpeg or gif format
logostringlogo icon in svg, png, jpeg or gif format
loaderstringloader icon in svg, png, jpeg or gif format

Response

PDP

Integrate Listing Item or Remove listing Modal

To use the Listing Item or Remove listing Modal feature, follow these steps:

Import the necessary modules from the @mojito-inc/secondary-market package:

import { ListItemContainer } from "@mojito-inc/secondary-market";

<ListItemContainer
        open={ open }
        image={ Image }
        config={ configuration }
        tokenDetails={ tokenDetails }
        isRemoveListing={ isRemoveListing }
        walletDetails={ walletDetails }
        onClickViewItem={ onCloseListItemModal }
        onClickBackToMarketPlace={ onCloseListItemModal }
        onCloseModal={ onCloseListItemModal }
        onConnectWallet={ onConnectWallet } />

Fill in the required parameters for the ListItemContainer

ParameterTypeRequiredDescription
openbooleanto open modal
configurationObjectConfiguration
ImageObjectImage
walletDetailsObjectWalletDetails
tokenDetailsObjectTokenDetails
isRemoveListingbooleanshould be true to render remove listing modal
onClickBackToMarketPlacefunction-✅function to handle custom redirection
onClickViewItemfunctionfunction to handle custom redirection
onConnectWalletfunction-✅function to handle connect wallet
onCloseModalfunctionfunction to handle close modal

Response

list item

Integrate Buy Now Modal

To use the Buy Now Modal feature, follow these steps:

Import the necessary modules from the @mojito-inc/secondary-market package:

import { BuyNow } from "@mojito-inc/secondary-market";

<BuyNow
        open={ open }
        config={ configuration }
        image={ Image }
        tokenDetails={ tokenDetails }
        walletDetails={ walletDetails }
        onClickViewItem={ onCloseBuyNowModal }
        onClickBackToMarketPlace={ onCloseBuyNowModal }
        onClickConnectWallet={ onConnectWallet }
        onClickDisconnectWallet={ onClickDisconnectWallet }
        onCloseModal={ onCloseBuyNowModal }
        onRefetchBalance={ onRefetchBalance } />

Fill in the required parameters for the BuyNow

ParameterTypeRequiredDescription
openbooleanto open modal
configurationObjectConfiguration
ImageObjectImage
walletDetailsObjectWalletDetails
tokenDetailsObjectTokenDetails
onRefetchBalancefunctionfunction to handle refetch balance logic
onClickBackToMarketPlacefunction-✅function to handle custom redirection
onClickViewItemfunctionfunction to handle custom redirection
onConnectWalletfunction-✅function to handle connect wallet
onClickDisconnectWalletfunctionfunction to handle disconnect wallet
onCloseModalfunctionfunction to handle close modal

Response

buy now

Integrate Make Offer Modal

To use the Make Offer Modal feature, follow these steps:

Import the necessary modules from the @mojito-inc/secondary-market package:

import { MakeOffer } from "@mojito-inc/secondary-market";

<MakeOffer
        open={ open }
        config={ configuration }
        image={ Image }
        tokenDetails={ tokenDetails }
        offerOrderId={ orderId }
        isCancelOffer={ isCancelOffer }
        walletDetails={ walletDetails }
        onClickViewItem={ onCloseMakeOfferModal }
        onClickBackToMarketPlace={ onCloseMakeOfferModal }
        onRefetchBalance={ onRefetchBalance }
        onConnectWallet={ onConnectWallet }
        onCloseModal={ onCloseMakeOfferModal } />

Fill in the required parameters for the MakeOffer

ParameterTypeRequiredDescription
openbooleanto open modal
configurationObjectConfiguration
ImageObjectImage
walletDetailsObjectWalletDetails
tokenDetailsObjectTokenDetails
isCancelOfferbooleanshould be true to render cancel offer modal
orderIdstringRequired for cancel offer
onRefetchBalancefunctionfunction to handle refetch balance logic
onClickBackToMarketPlacefunction-✅function to handle custom redirection
onClickViewItemfunctionfunction to handle custom redirection
onConnectWalletfunction-✅function to handle connect wallet
onCloseModalfunctionfunction to handle close modal

Response

Integrate Accept Offer Modal

To use the Accept Offer Modal feature, follow these steps:

Import the necessary modules from the @mojito-inc/secondary-market package:

import { AcceptAndRejectOffer } from "@mojito-inc/secondary-market";

<AcceptAndRejectOffer
        open={ open }
        config={ configuration }
        image={ Image }
        tokenDetails={ tokenDetails }
        orderId={ orderId }
        isRejectOffer={ isRejectOffer }
        walletDetails={ walletDetails }
        onClickViewItem={ onCloseOfferModal }
        onClickBackToMarketPlace={ onCloseOfferModal }
        onConnectWallet={ onConnectWallet }
        onCloseModal={ onCloseOfferModal } />

Fill in the required parameters for the AcceptAndRejectOffer

ParameterTypeRequiredDescription
openbooleanto open modal
configurationObjectConfiguration
ImageObjectImage
walletDetailsObjectWalletDetails
tokenDetailsObjectTokenDetails
isRejectOfferbooleanshould be true to render reject offer modal
orderIdstringshould pass order id to which order going to accept or reject
onClickBackToMarketPlacefunction-✅function to handle custom redirection
onClickViewItemfunctionfunction to handle custom redirection
onConnectWalletfunction-✅function to handle connect wallet
onCloseModalfunctionfunction to handle close modal

Response

📘

Note:

For complete documentation of the Secondary-marketplace SDK offerings, see the secondary-marketplace.