Skip to content

Instantly share code, notes, and snippets.

@yaronvel
yaronvel / gist:a48e79b50dd6d755a9b9461441cabd43
Created October 10, 2016 06:06
1st blood token implementation
/**
* ERC 20 token
*
* https://github.com/ethereum/EIPs/issues/20
*/
contract StandardToken is Token {
/**
* Reviewed:
* - Interger overflow = OK, checked
@yaronvel
yaronvel / experiment.go
Last active October 18, 2016 07:13
EXP opcode pricing
package main
import (
"fmt"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm/runtime"
)
contract SHA3_512_Wrapper {
function sponge(uint[9] M) constant returns(uint[16]);
}
contract Ethash {
[1404782, 15539400, 804716, 1924892, 16766102, 16498960, 1548194, 1436276, 6679612, 12642922, 14282244, 10745398, 3729706, 10346056, 10243992, 14942570, 10844660, 11474992, 11940260, 13844510, 11586038, 10682484, 16519760, 7949296, 15083760, 6710798, 15769364, 8564820, 7339820, 2167756, 10572706, 7617300, 1066884, 9344446, 7705576, 8913570, 6049872, 12345046, 3433192, 11760844, 4697898, 8894630, 1631962, 14029532, 13850934, 802304, 14764, 8988334, 6933886, 6959248, 14608884, 3994622, 15021690, 298536, 11093442, 8263918, 12001958, 3837772, 4810854, 6541392, 4920002, 16446730, 4428298, 11445060]
import pickle
from pycoin.serialize import b2h, h2b
from pycoin import encoding
import rlp
from ethereum import tester, utils, abi, blocks, transactions
import sha3, copy
def get_seedhash(block_number):
[13282552, 1105031, 11812463, 2790415, 2625720, 4539816, 5187220, 7735247, 12827669, 8220447, 3771673, 6107320, 4322584, 499202, 9249127, 10483756, 3398027, 3569374, 9182293, 3054465, 12067048, 5155926, 12645521, 10530848, 434740, 8209194, 10983812, 10821517, 2058423, 4629979, 11416915, 8357745, 1421006, 5312874, 9603835, 1436343, 10252321, 6548335, 5237163, 8705311, 4940987, 374080, 1865848, 2998453, 12031173, 2455677, 3294052, 11569114, 4610178, 7289900, 8507270, 1839564, 5626595, 5680798, 12309, 6314194, 11400756, 3646046, 552207, 1118353, 12823889, 11905227, 7079429, 3667145]
These are indices for block_number = 2400000
header_hash = h2b("100cbec5e5ef82991290d0d93d758f19082e71f234cf479192a8b94df6da6bfe")
nonce = h2b("307692cf71b12f6d")
lkp_data = [114148657133969591545450271717988636480209274784206358563543726318055334518271L, 89795981028699717886903036313496476852375289500458540304356196595220384228288L, 85271898368467201078649075854113535169148563238340278454657274830551855386957L, 76108133355715268787562502188840953643055921927300423802571337019180205929558L, 60274112510035166008835085130162116006929382107897411348016912120796471089543L, 22412701606784419975914469252078867544988637224991331531089096694599067657895L, 16808789258875691673323186658060623702513376767193144761460160675345611641603L, 97296751020650639337757190044598168586317262935957195289428184388604096827471L, 97660754303577170953435426933298517756249199140467776249264762880909840888241L, 115590348191056330971493158646642421463921756338953805017576812870371717000757L, 13431760336535420783937617900755477849640280457000886011262338885610433137531L, 39913017739008302693329735943640516734910356650838775293059711404770907439335L, 10401640186931945521222520350481419412432339777892
[{"constant":true,"inputs":[],"name":"simpleVote","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_scheme","type":"address"}],"name":"proposeScheme","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_scheme","type":"address"}],"name":"getVoteStatus","outputs":[{"name":"","type":"uint256[4]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_scheme","type":"address"},{"name":"_yes","type":"bool"}],"name":"voteScheme","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"collectFoundersShare","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[{"name":"tokenName","type":"string"},{"name":"tokenSymbol","type":"string"},{"name":"_founders","type":"address[]"
[{"constant":true,"inputs":[],"name":"simpleVote","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"contributionId","type":"bytes32"},{"name":"_yes","type":"bool"}],"name":"voteContribution","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_contributionDesciption","type":"string"},{"name":"_tokenReward","type":"int256"},{"name":"_reputationReward","type":"int256"}],"name":"submitContribution","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"inputs":[{"name":"_controller","type":"address"},{"name":"_submissionFee","type":"uint256"},{"name":"_simpleVote","type":"address"}],"payable":false,"type":"constructor"}]
function verifyAgt( uint rootHash,
uint rootMin,
uint rootMax,
uint leaf32BytesHash,
uint leafNonce,
BlockHeader leafHeader,
uint branchIndex,
uint[] countersBranch,
uint[] hashesBranch ) constant internal returns(bool) {