HashLips / hashlips_nft_minting_dapp

HashLips minting dapp is a quick and easy way to connect your smart contract and start minting NFTs.
MIT License
1.02k stars 984 forks source link

Code modification #145

Closed cesar4design closed 1 year ago

cesar4design commented 1 year ago

Code to change the selected price of the NFT. This is the improved part of the original repository.

const claimNFTs = () => {
    // let cost = CONFIG.WEI_COST;
    let cost = WEI_COST;
    let gasLimit = CONFIG.GAS_LIMIT;
    let totalCostWei = String(cost * mintAmount);
    let totalGasLimit = String(gasLimit * mintAmount);

    console.log('Mint Amount: ', mintAmount);
    console.log('Cost: ', cost);
    console.log('Total Cost In WEI: ', totalCostWei);
    console.log('Total Cost In ETH: ', totalCostWei / (baseWei * 100000));
    console.log('Gas Limit: ', totalGasLimit);
    console.log('Contract Address: ', CONFIG.CONTRACT_ADDRESS);
0rb5 commented 1 year ago

yes I can do that for you, your using this exact Template?

AbstractAlao commented 1 year ago

@cesar4design You would need to pass in the value from the text box into the cost of the NFT. I've updated mine to do dynamic pricing so something similar to this

const baseWei = 10000000000000;
const dynamicDisplayCost = () => {
    let round = roundUp(parseInt(data.totalSupply) + parseInt(mintAmount), 1000);
    let multiplier = round === 0 ? 1000 : round;

    return SET_COST_CONFIG(baseWei * multiplier);
  };

useEffect(() => {
    dynamicDisplayCost();
  });

A snippet of the top part of the function

const claimNFTs = () => {
    // let cost = CONFIG.WEI_COST;
    let cost = WEI_COST;
    let gasLimit = CONFIG.GAS_LIMIT;
    let totalCostWei = String(cost * mintAmount);
    let totalGasLimit = String(gasLimit * mintAmount);

    console.log('Mint Amount: ', mintAmount);
    console.log('Cost: ', cost);
    console.log('Total Cost In WEI: ', totalCostWei);
    console.log('Total Cost In ETH: ', totalCostWei / (baseWei * 100000));
    console.log('Gas Limit: ', totalGasLimit);
    console.log('Contract Address: ', CONFIG.CONTRACT_ADDRESS);