Skip to content

Instantly share code, notes, and snippets.

@D-Nice
D-Nice / etherUnitConverter.sol
Last active September 17, 2016 23:16
An Ethereum unit converter living on the blockchain with some caveats (doesn't support decimal places and they get truncated)
pragma solidity ^0.4.0;
contract EtherUnitConverter {
/*
* Ethereum Units Converter contract
*
* created by: D-Nice
* contract address: 0x52070b253406fc4F2bf71dBaF910F66c45828DBA
*/
@D-Nice
D-Nice / stringaskey.sol
Created August 20, 2016 18:01 — forked from axic/stringaskey.sol
How to use string as a key in a mapping in Solidity aka. how to store short strings cheape
//
// In Solidity, a mapping is like a hashmap and works with `string` like this:
// mapping (string => uint) a;
//
// However it doesn't support accessors where string is a key:
// mapping (string => uint) public a;
//
// "Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented."
//
// An accessor returns uint when called as `a(string)`.
@D-Nice
D-Nice / DatePayout.sol
Last active November 28, 2016 11:44
Contract for locking a certain amount of ether until a set date
contract DateTime {
/*
* Credit to pipermerriam for this utility contract
*
* Date and Time utilities for ethereum contracts
*
* address: 0x1a6184cd4c5bea62b0116de7962ee7315b7bcbce
*/
function toTimestamp(uint16 year, uint8 month, uint8 day) constant returns (uint timestamp);
contract ForkSplitterConduit {
//Tracks whether hard fork is effective on this chain. True means the fork is passed, false it hasn't.
bool forked = false;
//Identifies on which network fork this contract should do transfers. True transfers only on a hard-fork network, and false on the original network.
bool transferOnlyFork;
//Hard-fork DAO withdrawal contract
address constant C = 0xbf4ed7b27f1d666546e30d74d50d173d20bca754;
//In Constructor you set whether you want this contract to operate on hard fork or non-hard fork network
// Set to true for transfers to only complete on hard fork, and false for non-hard fork
contract Creator {
function newContract(bytes data) public returns (address) {
address theNewContract;
uint s = data.length;
assembly {
calldatacopy(mload(0x40), 68, s)
theNewContract := create(callvalue, mload(0x40), s)
}
@D-Nice
D-Nice / testingDAO v1.1
Last active June 5, 2016 19:10
DAO for use in testing and finding any bugs in V1.1 features
/*
- Bytecode Verification performed was compared on second iteration -
This file is part of the DAO.
The DAO is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
/**
* 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.