Hello, first time up in here! Seen some great helpful stuff so far.
Trying to go further down into the code rabbit hole and was wondering if some kind soul could spare a few minutes ripping apart my efforts so far?
I’m no expert in this stuff so thought about reaching out.
const ABI = [XYZ];
const contAdd = "XYZ";
//Async Minting Function
async function mint(){
//Web3 User Account
let web3 = new Web3(provider);
let account = await web3.eth.getAccounts();
//Mint Inputs
let useraddress = account[0];
let mintAmount = 1; // soon to be variable from document.getElementById('#mint-qty');
//Contract Deploy
let contract = new web3.eth.Contract(abi, contAdd);
let cost = 50000000000000000;
let gasLimit = 285000;
let totalCostWei = String(cost * mintAmount);
let totalGasLimit = String(gasLimit * mintAmount);
console.log("Cost: ", totalCostWei);
console.log("Gas limit: ", totalGasLimit);
await contract.methods.mint(useraddress,mintAmount)
.send({gasLimit: String(totalGasLimit), to: contAdd, from: useraddress, value: totalCostWei, gasPrice:2500000001})
.once("error", (err) => {
console.log(err);
})
.then((receipt) => {
console.log(receipt);
});
}
I’m basically trying to adapt to mint like what’s in here:- https://github.com/HashLips/hashlips_nft_minting_dapp
Can get metamask to popup, but the data in the transaction is bigger than it should be.
My data in transaction DATA:-
Parameters:
[
{
"type": "address"
},
{
"type": "uint256"
}
]
What it should be:
Parameters:
[
{
"type": "uint256"
}
]
I can see in that react code that there’s only “.mint(mintAmount)”
So I guess my question is what am I missing in the code snip above to mint, the demo only takes ‘mintAmount’ but mine is ‘useraddress,mintAmount’. Any work around, don’t mind sounding dumb in the aid of learning.
ABI =
{
"inputs": [
{
"internalType": "address",
"name": "_to",
"type": "address"
},
{
"internalType": "uint256",
"name": "_mintAmount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
This is going to make someone lol for sure.
Cheers in advance
CTF