//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; contract CropInsurance { address public farmer; uint public premium; bool public isCropFailure; constructor() { farmer = msg.sender; premium = 0.01 ether; isCropFailure = false; } function payPremium() public payable { require(msg.value == premium, "Incorrect premium amount"); } function reportCropFailure() public { require(msg.sender == farmer, "Only farmer can report crop failure"); isCropFailure = true; } function withdraw() public { require(msg.sender == farmer, "Only farmer can withdraw premium"); payable(msg.sender).transfer(premium); } }
0.4.18