Skip to content

Instantly share code, notes, and snippets.

View asselstine's full-sized avatar

Brendan Asselstine asselstine

View GitHub Profile
@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 / 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 / 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 / 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 / HoneyPot.sol
Created September 12, 2018 02:46
HoneyPot Contract
pragma solidity ^0.4.8;
contract HoneyPot {
mapping (address => uint) public balances;
function HoneyPot() payable {
put();
}
function put() payable {
balances[msg.sender] = msg.value;
}
function get() {
@asselstine
asselstine / example.js
Created September 6, 2018 22:52
An example of using MedCredits IPFS-backed encrypted HIPAA-compliant storage
import { ipfsStorage } from 'medcredits'
async function getCaseDetails (ipfsHash, encryptionKey) {
const detailsJson = await ipfsStorage.downloadJson(ipfsHash, encryptionKey)
const details = JSON.parse(detailsJson)
const [firstImageDataUrl, secondImageDataUrl] = await Promise.all([
ipfsStorage.downloadImage(details.firstImageHash, props.caseKey),
ipfsStorage.downloadImage(details.secondImageHash, props.caseKey)
])
return {
@asselstine
asselstine / gist:e6abd9c192228fab30f2e45b790f78f0
Created September 6, 2018 22:46
Some snippets showing the case challenging code for arbitration
contract ChallengeManager is Ownable, Initializable {
using RegistryLookup for Registry;
Registry registry;
event ChallengeDoctorSet(address indexed _case, address indexed _patient, address indexed _challengingDoctor, bytes doctorEncryptedKey);
event ChallengingDoctorCleared(address indexed _case, address indexed _patient, address indexed _diagnosingDoctor);
event CaseChallenged(address indexed _case, address indexed _patient, address indexed _challengingDoctor);
event ChallengedCaseClosed(address indexed _case, address indexed _patient, address indexed _diagnosingDoctor, address _challengingDoctor);
@asselstine
asselstine / Export AWS profile
Created June 12, 2018 16:24
Bash function to easily export your AWS credentials
export_aws_profile() {
profile=$1
profile=${profile:-default}
echo "Exporting AWS profile $profile..."
export AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id --profile ${profile}`
export AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key --profile ${profile}`
}
@asselstine
asselstine / 3.json
Created April 11, 2018 22:02
Example network config
{
"migrationVersion": 1521830456,
"contracts": [
{
"contractName": "CryptoDoggies",
"address": "0xc7f2f998c937eec6c8a0a64e3ab8d1f089bf2e86"
}
]
}
@asselstine
asselstine / truffle.js
Last active February 6, 2018 22:50
Truffle configuration example that shows how to import ES6 style modules.
require('babel-register') // should already exist in Truffle webpack box
require('babel-polyfill') // added to appease zeppelin-solidity
require('babel-node-modules')([ // added so that we can include zeppelin-solidity test JS
'zeppelin-solidity' // module that has ES6 style files I wish to include
])
module.exports = {
networks: {
development: {
host: '127.0.0.1',