In this I have set modifier (msg.sender == sellerAddress
) which is not valid.
But in this scenario, I want to allow only and only sellerAddress to take ether from my contract. How can I allow only seller address to do this. As well as which kind of inputs I have to enter while executing contract?
contract ContractDemo {
address public buyerAddress;
address public sellerAddress;
uint public price; //price or charge for delivering parcel
modifier onlyBuyer() {
require(msg.sender == buyerAddress);
_;
}
modifier onlySeller() {
require(msg.sender == sellerAddress);
_;
}
constructor(address payable _sellerAddress) public payable {
buyerAddress = msg.sender;
sellerAddress = _sellerAddress;
price = msg.value;
}
function deliveredParcel(address payable _seller) onlySeller public payable returns(bool) {
require(msg.value == price);
_seller.transfer(msg.value);
return true;
}
}