This is my solidity function:
function bid(uint256 bidAmount) public payable {
require(vault.tokenExists(address(nftAddress), nftId, owner) == true, "There are no units of this token available for sale!");
require(msg.value == bidAmount, "Bid amount must be equal to sent value");
require(block.timestamp < endTime, "Auction has already ended");
require(bidAmount > winningBid, "Bid amount must be greater than the winning bid");
//Refund the previous winner's bid
if (winner != address(0)) {
winner.transfer(winningBid);
emit BidRefunded(winner, winningBid);
}
// Add the new bid to the mapping and update the winning bid
bids[msg.sender].push(Bid({bidder: payable(msg.sender), bidAmount: bidAmount}));
winningBid = bidAmount;
winner = payable(msg.sender);
emit NewBid(msg.sender, bidAmount);
}
I am trying to execute it using hardhat js:
const Auction = await AuctionContract.attach('0xA6558F9fEDD69F55B056b5233a1cFcad9d45d242');
const user_signer = new ethers.Wallet(account_one_privateKey, provider);
const tokenPrice1 = ethers.utils.parseEther('0.0000000000000002');
const sendValue = {
value: tokenPrice1,
};
const Bid = await Auction.connect(user_signer).bid(200000,sendValue);
console.log(Bid);
console.log(Bid.hash);
its throwing me this error:
reason: 'processing response error',
code: 'SERVER_ERROR',
body: '{"jsonrpc":"2.0","id":49,"error":
{"code":-32000,"message":"insufficient funds for transfer"}}\n',
account_one_privateKey
doesn't have money, that's why it gives you this error