2.0.0 • Published 2 years ago

mint.club-sdk v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mint.club-sdk

NPM JavaScript Style Guide

Demo

Please check out the demo code here.

Install

npm install --save mint.club-sdk

or

yarn add mint.club-sdk

Constants

These are all constants exported from the SDK.

import { ADDRESSES, BSC_MAINNET, BSC_TESTNET } from "mint.club-sdk";
NameTypeValue
BSC_MAINNETnumber56
BSC_TESTNETnumber97
ADDRESSES = {
  mintClubBond: {
    [BSC_TESTNET]: "0xB9B492B5D470ae0eB2BB07a87062EC97615d8b09",
    [BSC_MAINNET]: "0x8BBac0C7583Cc146244a18863E708bFFbbF19975",
  },
  mintClubZap: {
    [BSC_TESTNET]: "0xFC1Ccd12A3aFbf3e6E5ba134Fa446935D20bc2F6",
    [BSC_MAINNET]: "0x9111A272e9dE242Cf9aa7932a42dB3664Ca3eC9D",
  },
  mint: {
    [BSC_TESTNET]: "0x4d24BF63E5d6E03708e2DFd5cc8253B3f22FE913",
    [BSC_MAINNET]: "0x1f3Af095CDa17d63cad238358837321e95FC5915",
  },
  pancakeswapRouter: {
    [BSC_TESTNET]: "0xD99D1c33F9fC3444f8101754aBC46c52416550D1",
    [BSC_MAINNET]: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
  },
  wbnb: {
    [BSC_TESTNET]: "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
    [BSC_MAINNET]: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
  },
  busd: {
    [BSC_TESTNET]: "0xeD24FC36d5Ee211Ea25A80239Fb8C4Cfd80f12Ee",
    [BSC_MAINNET]: "0xe9e7cea3dedca5984780bafc599bd69add087d56",
  },
  usdt: {
    [BSC_TESTNET]: "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
    [BSC_MAINNET]: "0x55d398326f99059fF775485246999027B3197955",
  },
};

Functions

allowance

Returns the allowed spending of spender from owner in BigNumber.

Usage

import { allowance } from "mint.club-sdk";

const allowance = await allowance(tokenAddress, owner, spender, chainId?, onSuccess?, onError?);

Input parameters

ParameterTypeDescriptionRequired
tokenAddressstringBEP-20 Token addressYes
owneraddressOwner contract/wallet addressYes
spenderaddressSpender contract/wallet addressYes
chainIdnumberNetwork chain idNo
onSuccessfunction(BigNumber) => {}No
onErrorfunction(error) => {}No

Output

ParameterTypeDescription
allowanceBigNumberbignumber.js instance

approve

Returns the allowed spending of spender from owner in BigNumber.

Usage

import { approve } from "mint.club-sdk";

await approve(tokenAddress, spender, signer, amount?, chainId?, onStart? onSuccess?, onError?);

Input parameters

ParameterTypeDescriptionRequired
tokenAddressstringBEP-20 Token addressYes
owneraddressOwner contract/wallet addressYes
spenderaddressSpender contract/wallet addressYes
amountnumberAmount to approve, defaults to ethers.constants.MaxUint256No
chainIdnumberNetwork chain idNo
onStartfunction() => {}No
onSuccessfunction(tx) => {}No
onErrorfunction(error) => {}No

balanceOf

Returns the balanceOf wallet address for a specific token.

Usage

import { balanceOf } from "mint.club-sdk";

const balance = await banlanceOf(tokenAddress, walletAddress, chainId?, onSuccess?, onError?);

getMintPrice

Returns the price of MINT based on pancakeswap.finance.

Usage

import { getMintPrice } from "mint.club-sdk";

const price = await getMintPrice(chainId?);

Input parameters

ParameterTypeDescriptionRequired
chainIdnumberNetwork chain idNo

Output

ParameterTypeDescription
pricenumberPrice of MINT

createToken

Invokes the createToken contract call from Mint.club bond contract.

import { createToken } from "mint.club-sdk";

const tx = await createToken(name, symbol, supply, signer, chainId?, onStart?, onSuccess?, onError?);

Input parameters

ParameterTypeDescriptionRequired
namestringName of tokenYes
symbolstringSymbol of tokenYes
supplynumberMax supply amountYes
signerSignerTransaction signer.Yes
chainIdnumberNetwork chain idNo
onStartfunction(tx) => {}No
onSuccessfunction(tx) => {}No
onErrorfunction(err) => {}No

Output

ParameterTypeDescription
txobjectTransaction receipt

createTokenAndBuy

Invokes the createTokenAndBuy contract call from Mint.club bond contract. Used for instant purchasing a token after it's minted to prevent front-running.

import { createTokenAndBuy } from "mint.club-sdk";

const tx = await createTokenAndBuy(name, symbol, supply, amount, referrer, signer, chainId?, onStart?, onSuccess?, onError?);

Input parameters

ParameterTypeDescriptionRequired
namestringName of tokenYes
symbolstringSymbol of tokenYes
supplynumberMax supply amountYes
amountstringAmount of token to purchaseYes
referreraddrressReferrer wallet addressYes
signerSignerTransaction signer.Yes
chainIdnumberNetwork chain idNo
onStartfunction(tx) => {}No
onSuccessfunction(tx) => {}No
onErrorfunction(err) => {}No

Output

ParameterTypeDescription
txobjectTransaction receipt

Input parameters

ParameterTypeDescriptionRequired
tokenAddressstringBEP-20 Token addressYes
walletAddressaddressWallet addressYes
chainIdnumberNetwork chain idNo
onSuccessfunction(BigNumber) => {}No
onErrorfunction(error) => {}No

Output

ParameterTypeDescription
balanceBigNumberbignumber.js instance

buyWithCrypto

Invokes the buy contract call from Mint.club bond contract. Used for Crypto -> MINT-based Token.

Usage

import { buyWithCrypto } from "mint.club-sdk";

const { value, tax, buy, BN } = await buyWithCrypto(amountIn, tokenIn, tokenAddress, slippage, referrer?, chainId?);
const tx = await buy();

Input parameters

ParameterTypeDescriptionRequired
amountInstringAmount to purchaseYes
tokenInobject{ address, decimals } Pass 'BNB' to address for native currency purchaseYes
tokenAddressaddressToken address to purchaseYes
slippagenumberSlippage amount. Pass 2 for 2%No
referreraddressReferrer addressNo
chainIdnumberNetwork chain idNo

Output

ParameterTypeDescription
valuenumberEstimated output value
taxnumberEstimated tax amount
BNBigNumberBigNumber instance of value. Used for precise calculation
buyasync functionA buy function that returns a Promise

sellToCrypto

Invokes the sell contract call from Mint.club bond contract. Used for MINT-based token -> Crypto.

Usage

import { sellToCrypto } from "mint.club-sdk";

const { value, tax, BN, sell, approve } = await sellToCrypto(amountIn, tokenAddress, tokenOut, slippage, referrer?, chainId?);
const tx = await sell();

Input parameters

ParameterTypeDescriptionRequired
amountInstringAmount to sellYes
tokenAddressaddressToken address to sellYes
tokenOutobject{ address, decimals } Pass 'BNB' to address to receive native currency after sellYes
slippagenumberSlippage amount. Pass 2 for 2%Yes
referreraddressReferrer addressNo
chainIdnumberNetwork chain idNo

Output

ParameterTypeDescription
valuenumberEstimated output value
taxnumberEstimated tax amount
BNBigNumberBigNumber instance of value. Used for precise calculation
sellasync functionA sell function that returns a Promise
approveasync functionAn approve function that returns a Promise. Null if allowance for token is greater than 0

buyWithMint

Invokes the buy contract call from Mint.club bond contract. Used for MINT -> MINT-based token.

Usage

import { buyWithMint } from "mint.club-sdk";

const { value, tax, buy, BN } = await buyWithMint(amountIn, tokenAddress, slippage, referrer?, isUSD?, forcedMintPrice?, chainId?);
const tx = await buy();

Input parameters

ParameterTypeDescriptionRequired
amountInstringAmount to purchaseYes
tokenAddressaddressToken address to purchaseYes
slippagenumberSlippage amount. Pass 2 for 2%Yes
referreraddressReferrer addressNo
isUSDbooleanPass true if amountIn is USD valueNo
forcedMintPricenumberCalculate the output amount with this forced MINT priceNo
chainIdnumberNetwork chain idNo

Output

ParameterTypeDescription
valuenumberEstimated output value
taxnumberEstimated tax amount
BNBigNumberBigNumber instance of value. Used for precise calculation
buyasync functionA buy function that returns a Promise

sellToMint

Invokes the sell contract call from Mint.club bond contract. Used for MINT-based token -> MINT.

import { sellToMint } from "mint.club-sdk";

const { value, tax, BN, sell, approve } = await sellToMint(amountIn, tokenAddress, slippage, referrer?, chainId?);
const tx = await sell();

Input parameters

ParameterTypeDescriptionRequired
amountInstringAmount to sellYes
tokenAddressaddressToken address to sellYes
slippagenumberSlippage amount. Pass 2 for 2%Yes
referreraddressReferrer addressNo
chainIdnumberNetwork chain idNo

Output

ParameterTypeDescription
valuenumberEstimated output value
taxnumberEstimated tax amount
BNBigNumberBigNumber instance of value. Used for precise calculation
sellasync functionA sell function that returns a Promise
approveasync functionAn approve function that returns a Promise. Null if allowance for token is greater than 0

getMintClubBondContract

Returns the ethers.js Contract of Mint.club Bond contract.

Usage

import { getMintClubBondContract } from "mint.club-sdk";

const contract =
  getMintClubBondContract(signer?, chainId?);
contract.someAwesomeCall();

Input parameters

ParameterTypeDescriptionRequired
signerobjectSignerNo
chainIdnumberNetwork chain idNo

getMintClubZapContract

Returns the ethers.js Contract of Mint.club Zap contract.

Usage

import { getMintClubZapContract } from "mint.club-sdk";

const contract =
  getMintClubZapContract(signer?, chainId?);
contract.someAwesomeCall();

Input parameters

ParameterTypeDescriptionRequired
signerobjectSignerNo
chainIdnumberNetwork chain idNo

getBEP20Contract

Usage

import { getBEP20Contract } from "mint.club-sdk";

const contract =
  getBEP20Contract(address, chainId?);
contract.someAwesomeCall();

Input parameters

ParameterTypeDescriptionRequired
addressstringToken addressYes
chainIdnumberNetwork chain idNo