Skip to content

Instantly share code, notes, and snippets.

@dryruner
dryruner / gist:2a6da4bb4da638770f55d4fc830f4fb5
Created June 2, 2019 08:13
Compute contract address in solidity
pragma solidity ^0.4.25;
contract ComputeContractAddress
{
function addressFrom(address _origin, uint _nonce) public pure returns (address) {
bytes memory data;
if(_nonce == 0x00) data = abi.encodePacked(byte(0xd6), byte(0x94), _origin, byte(0x80));
else if(_nonce <= 0x7f) data = abi.encodePacked(byte(0xd6), byte(0x94), _origin, byte(_nonce));
else if(_nonce <= 0xff) data = abi.encodePacked(byte(0xd7), byte(0x94), _origin, byte(0x81), uint8(_nonce));
else if(_nonce <= 0xffff) data = abi.encodePacked(byte(0xd8), byte(0x94), _origin, byte(0x82), uint16(_nonce));
@dryruner
dryruner / SimpleDice.sol
Last active August 22, 2020 23:58
DOSRandom() example
/**
*Submitted for verification at Etherscan.io on 2020-08-22
*/
pragma solidity ^0.5.0;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
@dryruner
dryruner / CoinbaseEthUsd.sol
Last active August 5, 2020 00:50
CoinbaseEthUsd Example
/**
*Submitted for verification at Etherscan.io on 2020-07-03
*/
pragma solidity ^0.5.0;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
@dryruner
dryruner / Rinkeby.md
Created February 28, 2018 08:16 — forked from learner-long-life/Rinkeby.md
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@dryruner
dryruner / payroll_test.js
Created January 23, 2018 18:02
payroll_test.js
var Payroll = artifacts.require("./Payroll.sol");
var BigNumber = require('bignumber.js');
// Nodejs doesn't support import..from.. syntax now.
//import expectThrow from "zeppelin-solidity/test/helpers/expectThrow";;
var expectThrow = async function(promise) {
try {
await promise;
} catch (err) {
const revert_op = err.message.search('revert') >= 0;
0x1738A04F8942489E68d39409bA9C5c7864C2D754
0x1738A04F8942489E68d39409bA9C5c7864C2D754
@dryruner
dryruner / ERC20
Created October 25, 2017 13:47
ERC20
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
contract ERC20 {
function totalSupply() constant returns (uint256 totalSupply);
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
@dryruner
dryruner / gist:8967d1d7638ec1a5c47de86429d5fb68
Created October 17, 2016 09:10 — forked from sshay77/gist:4b1f6616a7afabc1ce2a
google-search-url-parameters-query-string-
// ==UserScript==
// @name Google Search Better Privacy
// @description Delete unnecessary params and add useful params on Google Search.
// @version 0.0.4
// @include http://*.google.*/search*
// @include http://*.google.*/imgres*
// @include https://*.google.*/search*
// @include https://*.google.*/imgres*
// @exclude http://play.google.com/*
// @exclude http://mail.google.com/*
@dryruner
dryruner / gist:4390fb202d0b31dfffa77d1280521fb1
Created October 17, 2016 06:19 — forked from morgant/gist:1753095
Building GnuTLS on Mac OS X

Preparing the Build Environment

cd ~/Desktop
mkdir wget-build
cd wget-build

Building & Installing GMP 5.0.2