Skip to content

Instantly share code, notes, and snippets.

@testrain
testrain / gist:2a6da4bb4da638770f55d4fc830f4fb5
Created Jun 2, 2019
Compute contract address in solidity
View gist:2a6da4bb4da638770f55d4fc830f4fb5
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));
@testrain
testrain / SimpleDice.sol
Last active Aug 22, 2020
DOSRandom() example
View SimpleDice.sol
/**
*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".
@testrain
testrain / CoinbaseEthUsd.sol
Last active Aug 5, 2020
CoinbaseEthUsd Example
View CoinbaseEthUsd.sol
/**
*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".
@testrain
testrain / Rinkeby.md
Created Feb 28, 2018 — forked from cryptogoth/Rinkeby.md
How to get on Rinkeby Testnet in less than 10 minutes
View Rinkeby.md

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,

View 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;
View Rinkeby
0x1738A04F8942489E68d39409bA9C5c7864C2D754
View Kovan_test_ether
0x1738A04F8942489E68d39409bA9C5c7864C2D754
View 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);
@testrain
testrain / gist:8967d1d7638ec1a5c47de86429d5fb68
Created Oct 17, 2016 — forked from sshay77/gist:4b1f6616a7afabc1ce2a
google-search-url-parameters-query-string-
View gist:8967d1d7638ec1a5c47de86429d5fb68
// ==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/*
View gist:4390fb202d0b31dfffa77d1280521fb1

Preparing the Build Environment

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

Building & Installing GMP 5.0.2