Created
December 8, 2018 20:02
-
-
Save kanlanc/509563c368cdac8ba490dd7f5c040487 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.0+commit.1d4f565a.js&optimize=false&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.10; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >0.4.99 <0.6.0; | |
contract InsuranceClaimFactory{ | |
address public claimer; | |
InsuranceClaim[] public deployedInsuranceClaim; | |
function createInsuranceClaim () public { | |
InsuranceClaim newInsuranceClaim = new InsuranceClaim(msg.sender); | |
deployedInsuranceClaim.push(newInsuranceClaim); | |
} | |
function getDeployedInsuranceClaims () public view returns (InsuranceClaim[] memory){ | |
return deployedInsuranceClaim; | |
} | |
} | |
contract InsuranceClaim{ | |
struct Request { | |
address payable insuranceRecipient; | |
string personName; | |
uint value; | |
address payable hospitalRecipient; | |
bool complete; | |
} | |
Request[] public requests; | |
address public claimer; | |
constructor (address creator) public{ | |
claimer = creator; | |
} | |
modifier restricted(){ | |
require(msg.sender==claimer); | |
_; | |
} | |
function createRequest(string memory personName,address payable insuranceRecipient,uint value,address payable hospitalRecipient) public restricted{ | |
Request memory newRequest = Request({ | |
insuranceRecipient:insuranceRecipient, | |
value:value, | |
personName:personName, | |
hospitalRecipient:hospitalRecipient, | |
complete:false | |
}); | |
requests.push(newRequest); | |
} | |
function finalizeRequest (uint index) public restricted{ | |
Request storage request = requests[index]; | |
require(!request.complete); | |
request.hospitalRecipient.transfer(request.value); | |
request.complete = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment