Skip to content

Instantly share code, notes, and snippets.

View zmitton's full-sized avatar
🦎
removing code > adding code

Zac Mitton zmitton

🦎
removing code > adding code
  • New York
View GitHub Profile
contract escrow {
mapping (uint => Holding) public holdings;
uint public numHoldings;
address god;
bool killable = true;
struct Holding {
uint amount;
address receiver;
bool unSpent;
// 4 1 1 1
// - = - + - + -
// n a b c
// 5:
// 4/5 = 1/2 + 1/5 + 1/10
// 6:
// 2/3 = 1/3 + 1/6 + 1/6
//Lib1 deployed at Ropsten : 0x09c3aAE78AA34c91B56fc6AbFE2e5a0AbceAaD45
//IdentityFactory deployed at Ropsten : 0xE8fe77d1576d0972d453b49bfAA84d716173D133
pragma solidity ^0.4.4;
library Lib1{
function findAddress(address a, address[] storage arry) returns (int){
for (uint i = 0 ; i < arry.length ; i++){
if(arry[i] == a){return int(i);}
}
return -1;
contract ContractProxy {
address public owner;
address public destination;
modifier onlyOwner(){ if (msg.sender == owner) _; }
function ProxyDapp(){ owner = msg.sender; }
//main function called by all users
function forward(bytes data) {
0x1F4E7Db8514Ec4E99467a8d2ee3a63094a904e7A
@zmitton
zmitton / rlp
Created October 20, 2017 13:17
const THRESHOLD = 0x37//maximum length that can be encoded in a single byte
const STRING_OFFSET = 0x80
const LIST_OFFSET = 0xc0
var encode = (input)=>{
switch(true){
case input instanceof Buffer: // string
var length = input.length
if(length === 1 && input[0] < STRING_OFFSET){ return input
}else{ return Buffer.concat([encodeLength(length, STRING_OFFSET), input]) }
@zmitton
zmitton / rlp.java
Last active November 11, 2017 17:15
import java.util.Arrays;
import java.util.LinkedList;
import javax.xml.bind.DatatypeConverter;
import java.lang.Byte;
import java.math.BigInteger;
class partial{
partial(Object body, int pointer){
this.body = body;
this.pointer = pointer;
const THRESHOLD = 0x37//maximum length that can be encoded in a single byte
const STRING_OFFSET = 0x80
const LIST_OFFSET = 0xc0
const LIST_OFFSET = 0xc0
const LIST_OFFSET = 0xc0
const LIST_OFFSET = 0xc0
var encode = (input)=>{
switch(true){
@zmitton
zmitton / augur.md
Last active August 7, 2018 19:51
Prediction Market Order-books

AUGUR

Will the Astros win the world series?

In a standard bet like this (with 2 outcomes (Y and N)), the participants each put in amounts totaling 1ETH, and a "yes share" and "no share" are created for the betting participants. When the outcome has been established the winning share becomes redeemable for 1ETH.

But how do the parties agree on what % of the ETH each should pay if the bet is not 50/50 odds? Order books can be created with Y Bids and N Bids (only bids because no one has any to sell). Whenever the highest bids from each order book add to >= 1, a "match" is made and the contract mints shares to accommodate them. Its kindof cool, and slightly different from standard order books.

@zmitton
zmitton / ballot.sol
Created October 20, 2018 02:28
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.4.25+commit.59dbf8f1.js&optimize=true&gist=
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {