Skip to content

Instantly share code, notes, and snippets.

View tjade273's full-sized avatar

Tjaden Hess tjade273

View GitHub Profile
@tjade273
tjade273 / ProfitShare.sol
Created September 10, 2015 22:34
Profit Splitting Contract
contract ProfitShare{
address owner;
uint public totalShares;
uint public threshold;
address[] public shareholders;
mapping(address => uint) public shares;
function ProfitShare(){
owner = msg.sender;
}
@tjade273
tjade273 / gist:6a669d60f8063abd8043
Created September 18, 2015 03:37
MultiSend.sol
contract MultiSend{
function multisend(address[] addrs, uint[] amounts) public {
uint sum;
for(uint i; i< amounts.length; i++){
sum++;
}
if(addrs.length != amounts.length || sum > msg.value){
addrs[addrs.length]; // Throw Exception
}
else{
contract BTCRelay{
function getLastBlockHeight() public returns(int256);
function getBlockHash(int256) public returns(int256);
}
contract Powerball{
mapping(address => uint8[6][]) public tickets;
mapping(address => uint) public balances;
uint public roundStart;
@tjade273
tjade273 / LamportVerify.sol
Created February 9, 2016 15:24 — forked from anonymous/LamportVerify.sol
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/?gist=
library LamportVerify{
function getBit(bytes32 data, uint256 index) constant returns(uint8) { // gets bit `i` from data
return uint8(uint256(data) / (2**((255-index)))) & 0x01;
}
function verify_sig(bytes32 msgHash, bytes32[512] pubKey, bytes32[256] signature) returns(bool){
for(uint i; i < 256; i++){
bytes32 pub;
@tjade273
tjade273 / HashLadder
Created February 15, 2016 00:56 — forked from anonymous/HashLadder
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/?gist=
library HashLadder{
function genPubKey(bytes32[2][32] privKey) returns (bytes32[2][32]){
bytes32[2][32] memory pubKey;
for(uint8 i; i< 32; i++){
bytes32 pa = privKey[i][0];
bytes32 pb = privKey[i][1];
for(uint k; k<258; k++){
pa = sha3(pa);
pb = sha3(pb);
@tjade273
tjade273 / HashLadder
Created February 19, 2016 16:51 — forked from anonymous/HashLadder
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/?gist=
library HashLadder{
function genPubKey(bytes32[2][32] privKey) returns (bytes32[2][32]){
bytes32[2][32] memory pubKey;
for(uint8 i; i< 32; i++){
bytes32 pa = privKey[i][0];
bytes32 pb = privKey[i][1];
for(uint k; k<258; k++){
pa = sha3(pa);
@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;
@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 / 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;
/**
* 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.