Skip to content

Instantly share code, notes, and snippets.

View amiller's full-sized avatar

Andrew Miller amiller

View GitHub Profile
@amiller
amiller / TinyDuplex.sol
Last active May 13, 2019 20:38
TinyDuplex.sol: minimalist duplex micropayment channel for Ethereum
pragma solidity ^0.4.22;
// ECE 398 SC - Smart Contracts and Blockchain Security
// http://soc1024.ece.illinois.edu/teaching/ece398sc/spring2018/
// Simpest possible duplex-micropayment channel
// - Funded with an up front amount at initialization
// - The contract creator is called "alice". The other party, "bob", is passed
// as an argument to the Constructor
// - There is no fixed deadline, but instead any party can initiate a dispute,
// which lasts for a fixed time
pragma solidity ^0.4.21;
// ECE 398 SC - Smart Contracts and Blockchain Security
// http://soc1024.ece.illinois.edu/teaching/ece398sc/spring2018/
contract SolidityChallenges {
// 1. Simple syntax
function arithmeticA(uint x) public pure returns(uint) {
// The following fragment of code is a for-loop that assigns a value
0x9C0b7d4fBeB2F8fdaD1822350562EB58dB29229D

If I hardforked: a doxxing of Satoshi Nakamoto

By Andrew Miller

If I hardforked would he mine it. Would he mine it if I forked it. 
Would he mine it would Satoshi would Satoshi would would he mine it. 
If Satoshi if I hardforked if I hardforked if Satoshi. 
Would he mine it if I forked it if I hardforked if Satoshi. 
Would he mine it if Satoshi if Satoshi if I softforked. 

If I hardforked if Satoshi if Satoshi if I softforked.

from Crypto.Hash import SHA256
from binascii import hexlify, unhexlify
import random
### Basic utilities
def hash(x):
assert type(x) is str
return SHA256.new(x).digest()
pragma solidity ^0.4.0;
// This contract is used for making a new opcode via a softfork.
// It works for opcodes that just evaluate an arbitrary function,
// returning y = f(x).
//
// The idea is to create a contract that implements an arbitrary key-value
// mapping, but miners (after the softfork) enforce that the only updates to the
// contract respect the correct function.
//
pragma solidity ^0.4.0;
// This contract is used for making a new opcode via a softfork.
// It works for opcodes that just evaluate an arbitrary function,
// returning y = f(x).
//
// The idea is to create a contract that implements an arbitrary key-value
// mapping, but miners (after the softfork) enforce that the only updates to the
// contract respect the correct function.
//
@amiller
amiller / testcontract.sol
Created June 14, 2017 18:42 — forked from anonymous/testcontract.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-v0.4.11+commit.68ef5810.js&optimize=undefined&gist=
pragma solidity ^0.4.0;
contract TestContract {
struct Proposal {
uint voteCount;
string description;
}
address public owner;
Proposal[] public proposals;
#! python2.7
#
# tinybitcoinpeer.py
# A toy bitcoin node in Python. Connects to a random testnet
# node, shakes hands, reacts to pings, and asks for pongs.
# - Andrew Miller https://soc1024.com/
#
# Dependencies:
# - gevent
# - https://github.com/petertodd/python-bitcoinlib
amiller@amiller-lenovo ~/installing/parity $ target/debug/parity --testnet --nodiscover --bootnodes "" -l network=trace --log-file parity.log
Adding ver.lock
Executed 1 upgrade scripts - ok
2016-07-15 18:24:30 INFO:parity: Starting Parity/v1.3.0-unstable-d14b687-20160715/x86_64-linux-gnu/rustc1.10.0
2016-07-15 18:24:30 INFO:parity: Using state DB journalling strategy fast
2016-07-15 18:24:30 INFO:ethcore::service: Configured for Morden using Ethash engine
enode://c9b35f1370d9d5b36d6d2a5c78192d3c46d0ccae0f5cad37209f1b366de3585ea59a81e69250eaaebd951e206522877f639d8354c7c82865a328ba7b0c359c8f@0.0.0.0:30303
2016-07-15 18:24:31 INFO:mode: Public node URL: enode://c9b35f1370d9d5b36d6d2a5c78192d3c46d0ccae0f5cad37209f1b366de3585ea59a81e69250eaaebd951e206522877f639d8354c7c82865a328ba7b0c359c8f@0.0.0.0:30303
2016-07-15 18:24:32 DEBUG:network: Connecting peers: 0 sessions, 0 pending, 0 started
2016-07-15 18:24:33 DEBUG:network: Connecting peers: 0 sessions, 0 pending, 0 started