I have the following code where I can have my users mint with this contract.
It works fine on Remix, but this contract fails on my app.
The reason why it fails on my app is simple: Amount is not specified when Metamask pops up.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
contract SimpleMintContract is ERC721, Ownable {
uint256 public mintPrice = 0.01 ether;
uint256 public totalSupply;
uint256 public maxSupply;
bool public isMintEnabled;
mapping(address => uint256) public mintedWallets;
constructor() payable ERC721('Simple Mint', 'SIMPLEMINT'){
maxSupply = 20;
}
function toggleIsMintedEnabled() external onlyOwner {
isMintEnabled = !isMintEnabled;
}
function setMaxSupply(uint256 maxSupply_) external onlyOwner {
maxSupply = maxSupply_;
}
function mint() external payable {
require(isMintEnabled, 'minting not enabled');
require(mintedWallets[msg.sender] < 5, 'exceeds max per wallet');
require(msg.value == mintPrice, 'wrong value');
require(maxSupply > totalSupply, 'sold out');
mintedWallets[msg.sender]++;
totalSupply++;
uint256 tokenId = totalSupply;
_safeMint(msg.sender, tokenId);
}
}
This is the screenshot on Remix. As you can see the amount is injected right.
On the other hand, this is what I get from my app. Amount is missing. So it fails.
I think I miss something very basic here. Could anyone point me to right direction?
Thank you.