Mint Club V1 Docs
  • Introduction
  • Fair Launch Tokens
  • To-do list
  • Contracts
  • FAQ
  • Announcement
  • Get Started
    • User Guide
      • Create Smart Token
      • Swap Smart Tokens
      • Buy MINT
      • User Guide (Russian, not official)
    • Trading Fees / Referral
    • Widget Link
    • Add MINT to your wallet
  • Developers
    • Code Snippets for Node scripts
    • Connect Wallet (React.js)
    • Mint.club Javascript SDK
      • Contract Interaction (React.js)
        • Minting a new token
        • Transferring a token
        • Buy & Sell
  • Tokenomics
    • Smart Token Bonding Curve
    • MINT and Smart Tokens
    • CREATOR Token
  • Others
    • Terms
    • Protocol Disclaimer
  • Resources
    • Mint.club (website)
    • Buy MINT (PancakeSwap)
    • Buy MINT (StealthEX)
    • Github
    • Audit Report
    • Twitter
    • Telegram
  • Old Docs
    • To-do list (deprecated)
    • Pre-sign Up (finished)
      • Swap HUNT to MINT Token
      • MINT Community Airdrop
    • Swap HUNT to MINT Terms (finished)
    • MINT Airdrop Terms (finished)
Powered by GitBook
On this page
  1. Developers
  2. Mint.club Javascript SDK
  3. Contract Interaction (React.js)

Minting a new token

This is an example of minting a new token.

import React from 'react';
import useWeb3Provider from 'hooks/useWeb3Provider';
import { getMintClubBondContract } from 'utils/contractHelpers';
import { useWeb3React } from '@web3-react/core';
import BigNumber from 'bignumber.js';

const BIG_TEN = new BigNumber(10);
const DEFAULT_TOKEN_DECIMAL = 18;

function CreateComponent() {
    const provider = useWeb3Provider();
    const { account } = useWeb3React();
    
    export const create = async (name, symbol, supply) => {
      const bondContract = getMintClubBondContract(provider.getSigner(account));
      return bondContract.createToken(
        name,
        symbol,
        new BigNumber(supply).times(BIG_TEN.pow(DEFAULT_TOKEN_DECIMAL)).toString(),
      );
    };

    export const createAndBuy = async (name, symbol, supply, amount, beneficiary) => {
      const bondContract = getMintClubBondContract(provider.getSigner(account));
      return bondContract.createAndBuy(
        name,
        symbol,
        new BigNumber(supply).times(BIG_TEN.pow(DEFAULT_TOKEN_DECIMAL)).toString(),
        new BigNumber(amount).times(BIG_TEN.pow(DEFAULT_TOKEN_DECIMAL)).toString(),
        beneficiary || AddressZero,
      );
    };
    
    return (
      <button
        onClick={async () => {
          try {
            const tx = // call create or createAndBuy depending on the situation
            await tx.wait();
          } catch (e) {
            console.error(e);
          }
        }}
      >
        Create Token
      </button>
    );
}
PreviousContract Interaction (React.js)NextTransferring a token