Auction Kit

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

Overview

The mojito-auction SDK is a library that provides abstractions and functionalities to simplify interaction with the on-chain auction in a Typescript/Javascript environment. It offers a comprehensive solution for integrating the auction feature into your application with a pre-designed user interface.

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

Prerequisites

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, and the Node.js version should be 18 or higher, along with either NPM (Node Package Manager) or Yarn. You can download and install Node.js from the official website here.
  2. Authentication Provider: To obtain the necessary token for authentication, you need to have an authentication provider set up. This can be a JWT (JSON Web Token) or an Auth0 token, which will be passed as the "token" property in the configuration.
  3. API URL: Determine the appropriate API URL to use based on your environment.
  4. NEXT js: We are recommended to use Next.js for this SDK.
  5. Personal Access Token: Create a personal access token on GitHub. You can generate a new token by visiting the following link. Make sure to enable the "read:packages" permission.

Installation and Setup

Step 1: Install the Auction Module

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

Install using NPM:

npm install --save @mojito-inc/mojito-auction

Install using Yarn:

yarn add @mojito-inc/mojito-auction

Also install following packages:

yarn add @mui/[email protected] @mui/[email protected] @apollo/client graphql

or

npm install @mui/[email protected] @mui/[email protected] @apollo/client graphql

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

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

  1. Determine the appropriate API URL for your desired environment:

    • For the development environment, set the API_URL to https://api-dev.mojito.xyz/query.
    • For the staging environment, set the API_URL to https://api-stg.mojito.xyz/query.
    • For the sandbox environment, set the API_URL to https://api-sandbox.mojito.xyz/query.
    • For the production environment, set the API_URL to https://api.mojito.xyz/query.
  2. Obtain a JWT token or Auth0 token from your authentication provider. This token will be used as the Bearer token in the provider configuration.

  3. In your JavaScript file, import the AuctionProvider component from @mojito-inc/mojito-auction.

  4. Wrap the provider using the AuctionProvider component and provide the necessary props:

    • theme: Optionally, you can pass a theme configuration object on customizing the appearance of the auction module.
    • clientOptions: Provide an object with the following properties:
      • uri: Set this property to the determined API_URL based on your environment.
      • token: Pass the obtained JWT token or Auth0 token as the value for this property. Use the format Bearer <Token>.
  5. Place your application's main component or the relevant component where you want to use the auction module inside the AuctionProvider component.

import { AuctionProvider } from '@mojito-inc/mojito-auction';

<AuctionProvider
  theme={theme}
  clientOptions={{
    uri: <API_URL>,
    token: 'Bearer <Token>',
  }}
>
  <YourApp />
</AuctionProvider>

Step 4: Import the AuctionContainer and Pass the Required Parameters

To use the AuctionContainer from the @mojito-inc/mojito-auction module and pass the required parameters, follow these steps:

  1. Import the AuctionContainer component from @mojito-inc/mojito-auction in your JavaScript file:

    import { AuctionContainer } from '@mojito-inc/mojito-auction';
    
  2. Place the AuctionContainer component in your code and provide the necessary parameters:

Parameters

PramsTypeRequiredDescription
itemIDstring
orgIDstring
imageURLstring
headerobjectHeader
tokenDetailsobjectTokenDetails
loginOrWalletTitlestring
loginOrWalletButtonstring
descriptionstring
etherScanImageURLstring
cryptoUnitenumCryptoUnit
connectedChainIdInt
walletAddressstring
placeBidobjectPlaceBid
auctionChainIdInt
providerethers.providers.Web3Provider
kycElementJSX.Element
loaderImageURLstring
showBuyNowbooleanAfter the off-chain auction has ended, you can display the 'Buy Now' button.
onSubmitfunctiononclick handle for buy now button
renderBreadCrumbevent() => JSX.Element
onClickLoginOrWalletevent()
onRefetchBalanceevent()

Header

PramsTypeRequired
titlestring
subTitlestring

TokenDetails

PramsTypeRequired
networkNamestring
tokenTypestring
contractAddressstring
tokenIdstring
creationDatestring
dimensionstring
onClickContractAddressevent()
onViewMetaDataevent()
onClickTokenIDevent()

PlaceBid

PramsTypeRequired
balanceInt
incrementPercentInt
bidCurrencyenum
termsURLstring
privacyURLstring

CryptoUnit

VariableValue
ETHETH
MATICMATIC
WETHWETH
WMATICWMATIC
  1. Call the AuctionContainer Component by providing the required parameters:
    <AuctionContainer
       itemID={ <itemID> }
       orgID={ <orgID> }
       imageURL={ <imageURL> }
       header={ <header> }
       tokenDetails={ <tokenDetails> }
       loginOrWalletTitle={ <loginOrWalletTitle> }
       loginOrWalletButton={ <loginOrWalletButton> }
       description={ <description> }
       etherScanImageURL={ <etherScanImageURL> }
       cryptoUnit={ <cryptoUnit> }
       connectedChainId={ <connectedChainId> }
       walletAddress={ <walletAddress> }
       placeBid={ <placeBid> }
       auctionChainId={ <auctionChainId> }
       provider={ <provider> }
       kycElement={ <kycElement> }
       loaderImageURL={ <loaderImageURL> }
    	 showBuyNow={ <showBuyNow> }
    	 onSubmit={ <onSubmit> }
       renderBreadCrumb={ <renderBreadCrumb> }
       onClickLoginOrWallet={ <onClickLoginOrWallet> }
       onRefetchBalance={ <onRefetchBalance> }
    />
    

Theme Config

  import { createTheme } from '@mui/material/styles';

  export const theme = createTheme({
    typography: {
      fontFamily: 'Abel',
    },
    components: {
      MuiCssBaseline: {
        styleOverrides: `
                @font-face {
                  font-family: "Abel";
                  font-style: normal;
                  font-display: swap;
                  font-weight: 400;
                  text-transform: none;
                  font-size: 14px;
                }
              `,
      },
      MuiButton: {
        styleOverrides: {
          root: {
            fontFamily: 'Abel',
            textTransform: 'none',
            borderRadius: '0px',
            fontWeight: 400,
            fontSize: '16px',
            backgroundColor: '#FFF',
            border: '1px solid #D7D8DB',
            color: '#242629',
            '&:hover': {
              backgroundColor: '#FFF',
              color: '#242629',
            },
          },
        },
      },
      MuiDialog: {
        styleOverrides: {
          paper: {
            boxShadow: '0px 8px 16px rgba(0, 0, 0, 0.08)',
          },
        },
      },
      MuiCheckbox: {
        styleOverrides: {
          root: {
            '&$checked': {
              backgroundColor: '000',
            },
          },
        },
      },
    },
    palette: {
      primary: {
        main: '#000',
      },
      secondary: {
        main: '#F9F9F9',
      },
      background: {
        default: '#FFFFFF',
      },
      text: {
        primary: '#000',
      },
      grey: {
        50: '#3C3F44',
        100: '#6C717A',
        200: '#BCBEC3',
        300: '#FAFBFB',
        400: '#868B93',
      },
      error: {
        main: '#BF1E18',
        dark: '#CE2818',
        light: '#FFDAD5',
        contrastText: '#BD2200',
      },
      divider: '#E8E9EC',
    },
    unstable_sxConfig: {
      borderColor: {
        themeKey: '#D7D8DB',
      },
    },
  });

📘

Note:

For complete documentation of the SDK offerings, see the NPM document.