【发布时间】:2022-08-14 15:11:40
【问题描述】:
我尝试将值从 0.025 ether 更改为 1 ether,然后它也显示相同的错误。
另外,我尝试过像 1/8 这样的有理数仍然无法工作。
看了一些答案,但他们没有解决错误。
我在其他项目中有相同的代码,它在那里工作。
我收到的错误
Uncaught (in promise) Error: invalid BigNumber value (argument=\"value\", value={\"value\":\"25000000000000000\"}, code=INVALID_ARGUMENT, version=bignumber/5.5.0)
Could not get the stack frames of error: TypeError: Cannot read properties of null (reading \'length\')
这是我的上市价格代码
uint256 listingPrice = 0.025 ether ; // Here ether is denoting the MATIC
function getListingPrice() public view returns (uint256) {
return listingPrice;
}
这是在 UI 中获取值的代码
async function putItem(url) {
const web3Modal = new Web3Modal();
const connection = await web3Modal.connect();
const provider = new ethers.providers.Web3Provider(connection);
const signer = provider.getSigner();
const { royalty } = formInput;
//NFT Contract
let contract = new ethers.Contract(nftAddress, NFT.abi, signer);
//minting the certificate
let transaction = await contract.createToken(url);
//waiting for the minting transaction to finish
let tx = await transaction.wait();
let event = tx.events[0];
let value = event.args[2];
let tokenId = value.toNumber(); //Token Id Of the NFT
console.log(tokenId)
//NFT Market Contract
contract = new ethers.Contract(nftMarketAddress, NFTMarket.abi, signer);
//fetching listing price from the contract
let listingPrice = await contract.getListingPrice();
listingPrice = listingPrice.toString();
//listing the certificate.
transaction = await contract.createMarketItem(
nftAddress,
tokenId,
{ value: (listingPrice) },
royalty,
index
);
//waiting for the transaction to complete
await transaction.wait();
console.log(\"completed\")
//navigate back to home page
}
如果需要更多详细信息,请发表评论。
-
你有没有深究过这个?我有同样的问题
-
你好,你溢出了,所以我建议你可以将该数字转换为 javascript 允许的数字,我认为它大约是 9007199254740991,因为可靠性更大,所以你可以检查一下。
-
我得到了这样的微笑错误,解决方案是什么?
标签: ethereum solidity metamask ethers.js