Skip to content

Instantly share code, notes, and snippets.

@Jesserc
Last active January 17, 2023 23:31
Show Gist options
  • Select an option

  • Save Jesserc/961153a43fbe1b5c772e59b58fac6fdc to your computer and use it in GitHub Desktop.

Select an option

Save Jesserc/961153a43fbe1b5c772e59b58fac6fdc to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract Bidder {
 uint256 highestBid;
 address currentHighestBidder;
function bid() external payable {
 require(msg.value > highestBid, "Bid higher");
 require(payable(currentHighestBidder).transfer(highestBid)); // ensure the bid is sent back, else revert the transaction
 highestBid = msg.value;
 currentHighestBidder = msg.sender;
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment