Giter VIP home page Giter VIP logo

Comments (12)

web-mickey avatar web-mickey commented on September 27, 2024

I get "× Error: Invalid number of parameters for "mint". Got 1 expected 2!" error when trying to mint one on Rinkeby network

from hashlips_nft_minting_dapp.

web-mickey avatar web-mickey commented on September 27, 2024

Looks like it is something with this line: blockchain.smartContract.methods .mint(mintAmount)

from hashlips_nft_minting_dapp.

migsdeving avatar migsdeving commented on September 27, 2024

Same happening with me

from hashlips_nft_minting_dapp.

hijak avatar hijak commented on September 27, 2024

Note: this dapp is designed to work with the intended NFT smart contract, that only takes one parameter in the mint function "mintAmount". But you can change that in the App.js file if you need to use a smart contract that takes 2 params.

change the line to

.mint(blockchain.account, mintAmount)

from hashlips_nft_minting_dapp.

bridgekp avatar bridgekp commented on September 27, 2024

Hello, I had this issue and changed the line which now allows for metamask to pop up and confirm the transaction.
However, the transaction always fails on rinkeby and the logs on the contract show failed too. The dapp then says sorry something went wrong. I cannot seem to figure out how to get the transactions to go through successfully.

Thanks!

from hashlips_nft_minting_dapp.

hijak avatar hijak commented on September 27, 2024

double check you have the correct abi loaded for your contract

from hashlips_nft_minting_dapp.

bridgekp avatar bridgekp commented on September 27, 2024

Ok, thank you, so I forgot to paste in my abi. I did that now I get this error:
image
Here is my code from that section:
image

Thanks for the help. I am self teaching
abi.txt

I also attached my abi

from hashlips_nft_minting_dapp.

hijak avatar hijak commented on September 27, 2024

hrm looks similar to mine. ive made some changes as it wasnt charging the user the correct amount

  const claimNFTs = () => {
    let cost = CONFIG.WEI_COST;
    let gasLimit = CONFIG.GAS_LIMIT;
    let totalCostWei = String(cost * mintAmount);
    let totalGasLimit = String(gasLimit * mintAmount);
    let costValue = blockchain.web3.utils.toWei((CONFIG.DISPLAY_COST * mintAmount).toString(), "ether")
    console.log("Cost: ", totalCostWei);
    console.log("Gas limit: ", totalGasLimit);
    setFeedback(`Minting your ${CONFIG.NFT_NAME}...`);
    setClaimingNft(true);
    blockchain.smartContract.methods
      .mint(blockchain.account, mintAmount)
      .send({
        gasLimit: String(totalGasLimit),
        to: CONFIG.CONTRACT_ADDRESS,
        from: blockchain.account,
        value: costValue,
      })
      .once("error", (err) => {
        console.log(err);
        setFeedback("Sorry, something went wrong please try again later.");
        setClaimingNft(false);
      })
      .then((receipt) => {
        console.log(receipt);
        setFeedback(
          `WOW, You have a ${CONFIG.NFT_NAME} citizen! go visit Opensea.io to view it.`
        );
        setClaimingNft(false);
        dispatch(fetchData(blockchain.account));
      });
  };

from hashlips_nft_minting_dapp.

bridgekp avatar bridgekp commented on September 27, 2024

I got it to the point where it tries to mint but the transaction always fails :(

Example transaction: 0x25ab6b1bb5a23d24da5bd657e681f24808243b307345e7cf9b87301ed4603d18

from hashlips_nft_minting_dapp.

JRyanJones avatar JRyanJones commented on September 27, 2024

What worked for me:
Modify the mint function in the contract to add an address as its first parameter (I called it recipient) and leave the uint256 mintAmount as the second. It's a bit of a kludge, but you could argue that it's now more flexible, as you could then mint an NFT for someone else. This is all abstracted away behind the Minting Dapp, however, and you can simply use blockchain.account (current user) as the first parameter to mint within App.js.
More to the point, Metamask pops up now and there are no errors when buying an NFT.

from hashlips_nft_minting_dapp.

av1428 avatar av1428 commented on September 27, 2024

Had the same issue and I figured out that its because my smart contract doesn't take an input for minting while the DAPP is trying to send an input, as the error reads for some got 1 expected 0, got 2 expected 0, got 2 expect 1 and so on... so I since mine doesn't take an input from user, its a straight forward mint. I removed the parameters passed within and made the function .mint()
Use it based on ur contracts mint function and it should work!
Cheers!!!

from hashlips_nft_minting_dapp.

KrazyNZ avatar KrazyNZ commented on September 27, 2024

const claimNFTs = () => {
let cost = CONFIG.WEI_COST;
let gasLimit = CONFIG.GAS_LIMIT;
let totalCostWei = String(cost * mintAmount);
let totalGasLimit = String(gasLimit * mintAmount);
let costValue = blockchain.web3.utils.toWei((CONFIG.DISPLAY_COST * mintAmount).toString(), "ether")
console.log("Cost: ", totalCostWei);
console.log("Gas limit: ", totalGasLimit);
setFeedback(Minting your ${CONFIG.NFT_NAME}...);
setClaimingNft(true);
blockchain.smartContract.methods
.mint(blockchain.account, mintAmount)
.send({
gasLimit: String(totalGasLimit),
to: CONFIG.CONTRACT_ADDRESS,
from: blockchain.account,
value: costValue,
})
.once("error", (err) => {
console.log(err);
setFeedback("Sorry, something went wrong please try again later.");
setClaimingNft(false);
})
.then((receipt) => {
console.log(receipt);
setFeedback(
WOW, You have a ${CONFIG.NFT_NAME} citizen! go visit Opensea.io to view it.
);
setClaimingNft(false);
dispatch(fetchData(blockchain.account));
});
};

Hey man this code above will that stop people getting my nft for free, for some reason people can mint direct on contract and not pay minting cost

from hashlips_nft_minting_dapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.