-
-
Save ienliven/6c7a809491a3d18078d8f63c8e279062 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.6+commit.2dabbdf0.js&optimize=false&gist=
This file contains hidden or 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.0; | |
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; | |
contract InsurancePOC is usingOraclize { | |
address public owner; | |
address public beneficiary; | |
string public identifier; | |
event newOraclizeQuery(string description); | |
event newOraclizeResponse(string description); | |
event hasDied(string description); | |
function InsurancePOC () { | |
owner = msg.sender; | |
beneficiary = 0; | |
identifier = ""; | |
} | |
function enable ( string ident, address addr ) { | |
if ( owner != msg.sender ) return; | |
if ( strCompare(identifier, "") == 0 ) identifier = ident; | |
if ( beneficiary == 0 ) beneficiary = addr; | |
} | |
function redeem() { | |
if ( msg.sender != owner ) return; | |
if ( owner != beneficiary ) return; | |
suicide(owner); | |
} | |
function __callback(bytes32 myid, string result) { | |
if (msg.sender != oraclize_cbAddress()) return; | |
newOraclizeResponse(strConcat("Oraclize respose received.", result)); | |
if ( strCompare(result, "Dead") == 0 ) { | |
owner = beneficiary; | |
hasDied(strConcat("Payment is cleared. Result: ", result)); | |
} | |
} | |
function heartbeat() payable { | |
if ( beneficiary == 0 ) return; | |
if ( strCompare(identifier, "") == 0 ) return; | |
newOraclizeQuery("Oraclize query was sent, standing by for the answer.."); | |
oraclize_query('URL', strConcat('html(http://oracle.integritas.net/users/', identifier, ').xpath(/html/body/p/span/text())')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment