0

Cannot deploy the code, it compiles normally on version 0.4.22 with the same compiler version. I have looked at the answer on a similar thread and changed version to 0.5.11, when I try to compile it in that version 3 more errors arise and I can't compile nor deploy. Here is the code in version 0.4.22

pragma solidity ^0.4.22;

contract SimpleAuction {
address public beneficiary1;
address public beneficiary2;
uint public auctionEnd;

// Current state of the auction.
// address public highestBidder;
//uint public highestBid;

address public highestBidder1;
uint public highestBid1;

address public highestBidder2;
uint public highestBid2;

uint public proportion;
uint public bid1;
uint public bid2;

mapping(address => uint) pendingReturns;

bool ended;

constructor (uint _biddingTime) public {
    beneficiary1 = msg.sender;
    beneficiary2 = msg.sender;
    auctionEnd = now + _biddingTime;
}

//fallback function that enables direct payments through metamask
function () public payable{
    makebid(proportion);
}


function makebid(uint var1) public payable {

    // saving variable1 as proportion
    proportion = var1;
    // creating mutiple bids;
    bid1 = var1 * msg.value;
    bid2 = 1 - var1 * msg.value;

    require(now <= auctionEnd);

    // If the bid is not higher, send the
    // money back.
    //require(msg.value > highestBid);

    //if (highestBid != 0) {
      //  pendingReturns[highestBidder] += highestBid;
    //}
    //highestBidder = msg.sender;
    //highestBid = msg.value;

//}

    require(bid1 > highestBid1);

    if (highestBid1 != 0) {

        pendingReturns[highestBidder1] += highestBid1;
    }
    highestBidder1 = msg.sender;
    highestBid1 = bid1;


    require(bid2 > highestBid2);

    if (highestBid2 != 0) {

        pendingReturns[highestBidder2] += highestBid2;
    }
    highestBidder2 = msg.sender;
    highestBid2 = bid2;

}
/// Withdraw a bid that was overbid.
function withdraw() public returns (bool) {
    uint amount1 = pendingReturns[highestBidder1];
    if (amount1 > 0) {
        pendingReturns[highestBidder1] = 0;

        if (!msg.sender.send(amount1)) {
            pendingReturns[highestBidder1] = amount1;
            return false;
        }

    uint amount2 = pendingReturns[highestBidder2];
    if (amount2 > 0) {

        pendingReturns[highestBidder2] = 0;

        if (!msg.sender.send(amount2)) {
            // No need to call throw here, just reset the amount owing
            pendingReturns[highestBidder2] = amount2;
            return false;
        }

    }
    return true;
  }

}

    // 1. Conditions
   require(now >= auctionEnd); // auction did not yet end
    require(!ended); // this function has already been called

    // 2. Effects
    ended = true;

    // 3. Interaction
    beneficiary1.transfer(highestBid1);
    beneficiary2.transfer(highestBid2);

}


}
  • The code doesn't compile. – Ismael Jan 4 at 17:51
  • it compiles for me (in compiler version 0.4.22+commit.4cb486b – Victoria Khelemska Jan 4 at 18:49
  • No, It doesn't compile. In remix solc 0.4.22 fails to load, with 0.4.26 it says browser/ballot.sol:109:11: ParserError: Expected identifier but got '(' require(now >= auctionEnd); // auction did not yet end ^. It is missing the declaration of the last function. – Ismael Jan 4 at 19:15
  • You have removed function auctionEnd() public { near the end. – Ismael Jan 4 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.