The Oraclize flight-delay insurance example, one oracle address apart
Context
Frontier and Homestead era deployment.
Key Facts
Description
Oraclize published a flight-delay insurance example alongside its query API, and this is that contract: a five-slot list of insured users and a five-slot list of investors, a premium paid in, and a callback that pays out when the oracle reports the flight. The source carries its author's line, Copyright (C) 2015 Thomas Bertani, Oraclize srl. Each deployment is byte-identical to the others apart from twenty bytes: the OraclizeI address it queries, pushed as a literal inside register(). That single constant is the whole difference between the copies of this contract on chain, which is what identifies them as one example redeployed rather than as separate contracts.
Source Verified
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
// Copyright (C) 2015 Thomas Bertani - Oraclize srl
// https://www.oraclize.it/service/api
contract OraclizeI {
function query(uint timestamp, byte[] formula_1, byte[] formula_2, byte[] formula_3, byte[] formula_4){}
function query(uint timestamp, address param, byte[] formula_1, byte[] formula_2, byte[] formula_3, byte[] formula_4){}
}
contract Insurance {
address[5] public users_list;
mapping (address => uint) public balances;
address[5] public investors_list;
mapping (address => uint) public investors;
uint public users_list_length;
uint public investors_list_length;
function register(byte[] formula_1a, byte[] flight_number, byte[] formula_3a, byte[] formula_4a, uint arrivaltime) returns (uint){
if (balances[msg.sender] > 0) return;
uint balance_busy = 0;
for (uint k=0; k<users_list_length; k++){
balance_busy += 5*balances[users_list[k]];
}
if (uint(address(this).balance)-balance_busy < 5*uint(msg.value)){ msg.sender.send(msg.value); return; }
OraclizeI oracle = OraclizeI(0x96d61c67487c5ce8bd683605f660e17b25c7c605);
oracle.query(arrivaltime+3*3600, msg.sender, formula_1a, flight_number, formula_3a, formula_4a);
balances[msg.sender] = msg.value;
users_list[users_list_length] = msg.sender;
users_list_length++;
}
function __callback(address sender, uint result){
var bal = balances[sender];
delete balances[sender];
if (result > 0) sender.send(5*bal);
for (uint k=0; k<users_list_length; k++){
if (users_list[k] == sender){
users_list[k] = 0x0;
}
}
}
function invest() {
if (investors[msg.sender] == 0){
investors_list[investors_list_length] = msg.sender;
investors_list_length++;
}
investors[msg.sender] += uint(msg.value);
}
function deinvest(){
if (investors[msg.sender] == 0) return;
uint balance_busy = 0;
for (uint k=0; k<users_list_length; k++){
balance_busy += 5*balances[users_list[k]];
}
if (balance_busy > uint(address(this).balance)) return;
uint invested_total = 0;
for (k=0; k<investors_list_length; k++){
invested_total += investors[investors_list[k]];
}
uint gain = investors[msg.sender] / invested_total * (address(this).balance - balance_busy);
msg.sender.send(gain);
investors[msg.sender] = 0;
for (k=0; k<investors_list_length; k++){
if (investors_list[k] == msg.sender) investors_list[k] = 0x0;
}
}
function get() returns (uint){
return balances[msg.sender];
}
function get_user(address user) returns (uint){
return balances[user];
}
function investment_ratio() returns (uint){
uint insured_customers_funds = 0;
for (uint k=0; k<users_list_length; k++){
insured_customers_funds += 5*balances[users_list[k]];
}
uint invested_total = 0;
for (k=0; k<investors_list_length; k++){
invested_total += investors[investors_list[k]];
}
uint ratio = invested_total / (uint(address(this).balance) - insured_customers_funds) * 100;
return ratio;
}
}External Links
Related contracts
Target
Same deployerTarget contract.
0x9e0ae8...c9428eSeptember 17, 2015GetSet
Same deployerA minimal getter/setter proxy from the Oraclize team. set() forwards calls to a hardcoded target contract, get() returns constant 255.
0x77beac...7e96c2September 17, 2015SimpleStorage
Same deployerThe storage example rewired to send a wei and return a constant
0x7aa73b...46473bSeptember 17, 2015Controller
Same deployerController contract.
0x3c9492...e332e5September 17, 2015Pool5x
Same deployerPool5x contract.
0x246b34...a8eebeSeptember 17, 2015Pool
Same deployerRevised Pool5x lottery prototype by Bertani (Oraclize), deployed 17 blocks after v1. Stores 5x msg.value and emits debug log events.
0xbb5cda...c483f9September 17, 2015