Skip to content

Instantly share code, notes, and snippets.

View tjade273's full-sized avatar

Tjaden Hess tjade273

View GitHub Profile
contract RaiseGas {
uint currentLimit;
uint lastPayout;
function RaiseGas(){
currentLimit = block.gaslimit;
lastPayout = block.number;
}
function(){
@tjade273
tjade273 / disasm.js
Last active May 3, 2017 14:06 — forked from anonymous/gist:d3bbdc55159879046345
Ethereum OPCODE disassembler
function disasm(code) {
if (!code)
return code;
var codes = code.match(/(..?)/g);
var dis = "";
for(var i = 1; i < codes.length; i++) {
var opcode = opcodes[codes[i]];
dis += i+". " + codes[i]+": "
if (!opcode) {
contract SplitFunds {
function split(address[] addrs){
if(!addrs[uint(block.blockhash(block.number-1)) % addrs.length].send(msg.value)) throw;
}
}
@tjade273
tjade273 / hash.py
Last active March 7, 2017 20:58
BKP 2017 Sponge Challenge
rom Crypto.Cipher import AES
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import sys
class Hasher:
def __init__(self):
self.aes = AES.new('\x00'*16)
def reset(self):
contract StringStore {
mapping(uint => string) public myStrings;
function storeString(string str, uint i) public {
myStrings[i] = str;
}
}
contract GetString {
function getString(address store, uint i) constant returns (string s, uint l){
bytes4 sig = bytes4(sha3("myStrings(uint256)"));
library LinkedList {
struct data {
uint80 head;
uint80 last;
uint80 count;
Item[] items;
}
uint80 constant None = uint80(0);
struct Item {
uint80 prev;
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@tjade273
tjade273 / Multisend.sol
Last active July 9, 2016 20:22
A contract that allows sending arbitrary amounts to a list of accounts in an atomic manner
//This version does not support sending to contracts with fallback functions. Funds that cannot be delivered are returned to the sender.
contract Multisend {
mapping(address => uint) public nonces;
function send(address[] addrs, uint[] amounts, uint nonce) {
if(addrs.length != amounts.length || nonce != nonces[msg.sender]) throw;
uint val = msg.value;
for(uint i = 0; i<addrs.length; i++){
if(val < amounts[i]) throw;
@tjade273
tjade273 / generic_proxy.sol
Created June 20, 2016 20:14 — forked from holiman/generic_proxy.sol
Example of creating a 'generic' proxy in Solidity/EVM Assembly. Further details at http://martin.swende.se/
contract complex{
address add;
uint aa;
uint bb;
function thrower()
{
throw;
}
@tjade273
tjade273 / ProofLib.sol
Created June 20, 2016 19:58 — forked from anonymous/ProofLib.sol
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-latest.js&optimize=undefined&gist=
library ProofLib {
struct Proof {
address defender;
address challenger;
bytes32 lVal;
bytes32 rVal;
uint lIndex;
uint rIndex;