I just deployed NFT Dapp on mainnet.
Estimated gas fee is too High. It's almost $10000
How can i fix it?
I never knew on local canache or rinkeby testnet
There was fine gas fee..
is it depend on truffle-config.js gas price?
I learn that based on complex of .sol code...
I use @openzapplin ERC-721, ERC721Enumerable, ERC721URIStorage, Ownable
and solc ^0.8.11
Here is my react web3 javascript for minting
await token.methods.createToken(uri, amount).send({from: account, value: tokens(_value)})
.on('receipt', (receipt) => {
setBuyDisable(false)
window.alert('Praying Bear successfully minted!')
console.log("resultado =", receipt)
})
.on('error', (error, receipt) => {
setBuyDisable(false)
console.log('Participate Error - Receipt', error, receipt)
console.log('Error - Message', error.message)
checkErrorMessage(error.message)
})
And my token.sol minttoken function is here
function createToken (string memory _uri, uint256 _amount) public payable returns (uint) {
require(totalSupply() < maxSupply - (_amount - 1), "Sorry, it just sold out");
uint256 currentprice = _amount == 1 ? soloPrice : _amount == 4 ? quatroPrice : tenPrice;
require(msg.value == currentprice, "Price must be equal to listing price");
payable(owner()).transfer(msg.value);
uint newItemId = 0;
for (uint i=0; i<_amount; i++) {
newItemId = minttoken(_uri);
}
return newItemId;
}
function minttoken (string memory _uri) private returns (uint) {
uint256 newItemId = totalSupply() + 1;
_mint(msg.sender, newItemId);
_uri = "ipfs://<HARDCODEDMYIPFSTOKEN>";
_uri = string(abi.encodePacked(_uri,"/",Strings.toString(newItemId),".json"));
_setTokenURI(newItemId, _uri);
return newItemId;
}
++ To fix this am I truffle migrate --reset do?