Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
104
rated 0 times [  106] [ 2]  / answers: 1 / hits: 7499  / 3 Years ago, thu, november 4, 2021, 12:00:00

I tried to send a request to my contract using ethersjs like this:


const web3Modal = new Web3Modal()
const connection = await web3Modal.connect()
const provider = new ethers.providers.Web3Provider(connection)
const signer = provider.getSigner()
const contract = new ethers.Contract(Contract, Market.abi, signer)
const price = ethers.utils.parseUnits(price.toString(), 18)

//const price = web3.utils.toWei(nft.price);
//const price = ethers.BigNumber.from(nft.price.toString()).toHexString();

const transaction = await contract.createSale(address, price)

await transaction.wait()

This code shows an error, I have tried all the solutions in this world, but nothing worked. => versions: nodejs 14.15, npm 8, web3 1.6, ethers 5.5


Any help?



Unhandled Rejection (Error): invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.5.0)



More From » web3js

 Answers
6

It looks like your price variable has the value undefined when you call createSale, resulting in an error.


Your issue is similar to: https://ethereum.stackexchange.com/questions/111042/cant-send-ether-to-smart-contract-using-ethers-js


[#704] Wednesday, October 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zariahdiamondz

Total Points: 649
Total Questions: 109
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
zariahdiamondz questions
Tue, Apr 20, 21, 00:00, 3 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Oct 6, 19, 00:00, 5 Years ago
;