0

when i compile the following code :

pragma solidity ^0.4.22;

contract SimpleAuctions {
    uint  public beneficiary; // 拍卖的受益人
    uint public auctionEnd; // 拍卖的结束时间
    address public highestBidder; // 当前的最高出价者
    uint public highestBid; // 当前的最高出价
    mapping(address => uint) pendingReturns; // 用于取回之前的出价
    bool ended; // 拍卖是否结束
    uint valueforbeneficiary;
    event HighestBidIncreased(address bidder, uint amount); // 出现新的最高价
    event AuctionEnded(address winner, uint amount); // 拍卖结束
    function SimpleAuction(uint[] valueforgoods) public pure {
        uint allvalue;
        uint i;
        for (i = 0;i < valueforgoods.length;i++){
            allvalue = allvalue + valueforgoods[i];

             if (valueforgoods[i] > highestBid) {  
                highestBid = valueforgoods[i];
            }
        }
    }
    function bid() public payable {
        require(
            now <= auctionEnd,
            "Auction already ended."
        );
        require(
            msg.value > highestBid,
            "There already is a higher bid."
        );
        if (highestBid != 0) {
            pendingReturns[highestBidder] += highestBid;
        }
        highestBidder = msg.sender;
        highestBid = msg.value;
        // beneficiary = allvalue;
        emit HighestBidIncreased(msg.sender, msg.value);
    }

    function auctionEnd() public {
        require(now >= auctionEnd, "Auction not yet ended.");
        require(!ended, "auctionEnd has already been called.");
        ended = true;
        emit AuctionEnded(highestBidder, highestBid);
        beneficiary.transfer(highestBid);
    }
}

i come with :Member "transfer" not found or not visible after argument-dependent lookup in uint256 beneficiary.transfer(highestBid)".How to modify it?

  • Please translate code comments in english ;) – Nicolas Massart Jul 25 '18 at 11:43
1
uint  public beneficiary;

should be declared instead as address

 address public beneficiary;

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.