【发布时间】:2023-02-15 22:56:44
【问题描述】:
我尝试创建一个函数来更新 NFT 的价格。但是我收到了这个错误
错误:无效的十进制值 (argument="value", value="[object Object]", code=INVALID_ARGUMENT, version=bignumber/5.7.0)
这是 Dapp.config.js 中的代码
const updatePrice = async (tokenId, newPrice) => { const web3Modal = new Web3Modal(); const connection = await web3Modal.connect(); const provider = new ethers.providers.Web3Provider(connection); const signer = provider.getSigner(); const contract = signerOrProvider(signer); console.log('New price', newPrice); console.log('Token ID', tokenId); await contract.updatePrice(tokenId, ethers.utils.parseUnits(newPrice.toString(), 'ether')); }这是我的 HTML
<div className='flex flex-col w-full'> <Input inputType='number' title='Update listing price' placeholder='Enter new listing price here ...' handleClick={(e) => {setFormInput({...formInput, price: e.target.value})}} /> <Button buttonType='primary' innerText='Update price' parentStyles='mt-5 rounded-full' handleClick={() => handleUpdatePrice(NFT.tokenId, formInput)} /> </div>这是我的 useStateSnippet
const [ formInput, setFormInput ] = useState({price : ''});
【问题讨论】:
标签: javascript node.js web3 decentralized-applications