0

我编译时遇到的错误是:(ParserError: Expected primary expression.price = _price; * (1 ether);)

我想为发起人添加一个 7 天的时间戳,以将所有资金全部添加到托管中,而不是一半以满足我预订我们的条件。这甚至可能作为我们加入的条件吗?我是否需要在我的智能合约中添加多重签名以使其在双方都安全,或者这段代码可以吗?谁能帮我解决这个问题?

//SPDX-许可证-标识符:MIT

pragma 可靠性 ^0.7.6;

合约托管{

    //VARIBALES
    enum State { NOT_INITIATED, AWAITING_PAYMENT, AWAITING_DELIVERY, COMPLETE }

    State public currState;

    bool public isBuyerIn;
    bool public isSellerIn;

    uint public price;

    address public buyer;
    address  payable public seller;

    //MODIFIERS
    modifier onlyBuyer() {
        require(msg.sender == buyer, "Only buyer can call this function"); _;
    }
    
    modifier escrowNotStarted() {
        require(currState == State.NOT_INITIATED);
        _;

    }

    //FUCTIONS
    constructor(address _buyer, address payable _seller, uint _price){
        buyer =_buyer;
        seller = _seller;
        price = _price; * (1 ether);     
    }

    function initContract() escrowNotStarted public{
        if(msg.sender == buyer) {
            isBuyerIn = true;
        }
        if (msg.sender == seller) {
            isSellerIn = true;
        }
        if (isBuyerIn && isSellerIn) {
            currState = State.AWAITING_PAYMENT;
        }
    }

    function deposit() onlyBuyer public payable {
        require(currState == State.AWAITING_PAYMENT, "Already paiid");
        require(msg.value == price, "Wrong deposit amount");
        currState = State.AWAITING_DELIVERY;
    
    }
    
    function confimDelivery() onlyBuyer payable public {
        require(currState == State.AWAITING_DELIVERY, "Cannot confirm delivery");
        seller.transfer(price);
        currState = State.COMPLETE;
    }

    function withdraw() onlyBuyer payable public {
        require(currState == State.AWAITING_DELIVERY, "Cannot withdraw at this stage");
        payable(msg.sender).transfer(price);
        currState = State.COMPLETE;
    }

}
4

1 回答 1

0

priceconstructor.

代替

// original code, extra semicolon
price = _price; * (1 ether);

// updated code, removed the semicolon
price = _price * (1 ether);
于 2021-12-23T11:14:58.087 回答