Skip to content

Instantly share code, notes, and snippets.

View asselstine's full-sized avatar

Brendan Asselstine asselstine

View GitHub Profile
@asselstine
asselstine / HoneyPotCollect.sol
Created September 12, 2018 02:47
HoneyPot Collector
pragma solidity ^0.4.8;
import "./HoneyPot.sol";
contract HoneyPotCollect {
HoneyPot public honeypot;
function HoneyPotCollect (address _honeypot) {
honeypot = HoneyPot(_honeypot);
}
function kill () {
suicide(msg.sender);
}
@asselstine
asselstine / IntUnderflow.sol
Created September 12, 2018 02:59
A Simple Example of Integer underflow
pragma solidity ^0.4.4;
/*
This contract is vulnerable to an attacker exploting
integer underflow. When you subtract from unsigned integers
at their lowest value (0), they cycle to their highest value.
Similarly, adding 1 to a max value unsigned integer will
cycle it to zero.
*/
@asselstine
asselstine / ganache.sh
Created September 12, 2018 03:13
Ganache startup script
#! /bin/sh
mkdir -p .ganache
ganache-cli \
--db .ganache \
-l 4700038 \
-i 1234 \
-e 100000000000 \
-a 10 \
-u 0 \
-m "rose dynamic miracle summer near tell genius label video check stumble miss"
@asselstine
asselstine / TCR_Example.sol
Last active September 12, 2018 17:13
An example of a contract that uses the DoctorRegistry
import 'medcredits-solidity/DoctorRegistry.sol';
contract CaseFactory {
uint8 constant DERMATOLOGY_CODE = 0x00001a83;
Case[] cases;
mapping (uint256 => address) public caseIndices;
DoctorRegistry doctorRegistry;
function CaseFactory(DoctorRegistry _doctorRegistry) {
@asselstine
asselstine / test.sh
Last active September 26, 2018 22:39
Docker separated ganache runner
docker run --rm -it -d --name ganache-cli -p 8145:8545 trufflesuite/ganache-cli:latest -e 10000000000 -l 4700038 -h 0.0.0.0; \
truffle compile --network=test && truffle test --network=test $1; \
EXIT_STATUS=$?; \
echo 'Shutting down ganache-cli...'; \
docker stop ganache-cli && echo 'Shut down ganache-cli' & \
exit $EXIT_STATUS
@asselstine
asselstine / Work.sol
Created November 1, 2018 11:23
Work Contract
pragma solidity ^0.4.24;
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';
import 'openzeppelin-solidity/contracts/token/ERC20/ERC20.sol';
import './IndexedAddressArray.sol';
contract Work is Ownable {
using IndexedAddressArray for IndexedAddressArray.Data;
address public jobManager;
@asselstine
asselstine / IndexedAddressArray.sol
Created November 1, 2018 11:24
Adds the ability to remove an address directly from an array
pragma solidity ^0.4.24;
library IndexedAddressArray {
struct Data {
address[] addresses;
mapping(address => uint256) indices;
}
function pushAddress(Data storage self, address _value) internal returns (uint256) {
@asselstine
asselstine / Work.sol
Created November 1, 2018 11:28
Work Contract supported deposits and withdrawals
pragma solidity ^0.4.24;
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';
import 'openzeppelin-solidity/contracts/token/ERC20/ERC20.sol';
import './IndexedAddressArray.sol';
contract Work is Ownable {
using IndexedAddressArray for IndexedAddressArray.Data;
address public jobManager;
@asselstine
asselstine / zosMerge.js
Created November 15, 2018 18:30
Merges the latest zos proxies into Truffle artifacts
#!/usr/bin/env node
const fs = require('fs')
const shell = require('shelljs')
const program = require('commander')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const writeFile = util.promisify(fs.writeFile)
program
@asselstine
asselstine / CoordinationGame.mmd
Created November 19, 2018 17:58
Coordination Game Mermaid Diagram
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.