Comments (12)
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.
Looks like it is something with this line: blockchain.smartContract.methods .mint(mintAmount)
from hashlips_nft_minting_dapp.
Same happening with me
from hashlips_nft_minting_dapp.
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.
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.
double check you have the correct abi loaded for your contract
from hashlips_nft_minting_dapp.
Ok, thank you, so I forgot to paste in my abi. I did that now I get this error:
Here is my code from that section:
Thanks for the help. I am self teaching
abi.txt
I also attached my abi
from hashlips_nft_minting_dapp.
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.
I got it to the point where it tries to mint but the transaction always fails :(
Example transaction: 0x25ab6b1bb5a23d24da5bd657e681f24808243b307345e7cf9b87301ed4603d18
from hashlips_nft_minting_dapp.
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.
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.
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)
- gas limit too high?
- Issue with parameter vs to: address
- interaction with thirdweb HOT 2
- Looking for a way to display totalSupply from the contract before connecting wallet HOT 1
- Error: Unhandled Rejection (Error): No "from" address specified in neither the given options, nor the default options.
- Confused about storage part
- error unsupported network HOT 3
- Logo error
- No option for whitelisting and pre-sale
- Code modification HOT 2
- Gas fee estimation error in polygon network
- Can't Get Minting Dapp to work with polygon Testnet HOT 1
- 71 vulnerabilities (13 low, 19 moderate, 36 high, 3 critical....
- Page Blank on Hostinger HOT 1
- Why from mobie the connect button don't open the metamask app?
- Issue deploying on Netlify
- npm warn deprecated
- Error Assertion failled HOT 1
- Uncaught runtime errors if i cancel the minting transaction.
- Error: Invalid number of parameters for "addData". Got 1 expected 4!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashlips_nft_minting_dapp.