【发布时间】:2022-01-04 15:05:37
【问题描述】:
我正在 CELO 上开发一个 NFT 铸币网站。我的 mint 函数如下所示:
function safeMint(address to) public payable {
require(msg.value >= mintPrice, "Not enough ETH sent; check price!");
uint256 tokenId = _tokenIdCounter.current();
_safeMint(to, tokenId);
_tokenIdCounter.increment();
// string memory token_uri=tokenURI(tokenId);
}
我的反应前端是这样的:
async function mintNFT() {
if (typeof window.ethereum !== 'undefined') {
await requestAccount()
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ethers.Contract(t_tokenAddress, Token.abi, signer);
try{
await window.ethereum.enable();
const transation = await contract.safeMint(userAccount);
await transation.wait();
fetchNFTIndex();
}
catch(e){
console.log(e.data.message);
}
}
}
当我使用 mintPrice =1 wei 或 ether 运行事务时出现以下错误: Error
当我使用 mintPrice=0 ether 或 wei 运行交易时,它工作正常。我不知道这里有什么问题。我的账户中有 5 个 celo,所以我有足够的资金,我假设以太币在 CELO 中转换和支付。 谁能理解这里的问题!
【问题讨论】:
标签: error-handling ethereum solidity metamask nft