Thank you so much I did that already actually I wrote a simple auction contract and It works with ether remix but I could not implement with javascript.
here is my contract.
pragma solidity >=0.7.0 <0.9.0;
contract SimpleAuction{
address payable public beneficiary;
uint public auctionEndTime;
address public highestBidder;
uint public highestBid;
mapping(address => uint) public pendingReturns;
bool ended = false;
event HighestBidIncrease(address bidder, uint amount);
event AuctionEnded(address winner, uint amount);
constructor(uint _biddingTime, address payable _beneficiary){
beneficiary = _beneficiary;
auctionEndTime = block.timestamp + _biddingTime;
}
function bid() public payable{
if (block.timestamp > auctionEndTime){
revert("The auction has already ended");
}
if (msg.value <= highestBid){
revert("There is alreay a higher or equal bid");
}
if (highestBid != 0){
pendingReturns[highestBidder] += highestBid;
}
highestBidder = msg.sender;
highestBid = msg.value;
emit HighestBidIncrease(msg.sender, msg.value);
}
function withdraw() public returns (bool){
uint amount = pendingReturns[msg.sender];
if(amount > 0){
pendingReturns[msg.sender] = 0;
if(!payable(msg.sender).send(amount)){
pendingReturns[msg.sender] = amount;
return false;
}
}
return true;
}
function auctionEnd() public{
if (block.timestamp < auctionEndTime){
revert ("The auction has not ended yet");
}
if (ended){
revert("the function auctionEnded has already been called");
}
ended = true;
emit AuctionEnded(highestBidder, highestBid);
beneficiary.transfer(highestBid);
}
}