Last active
December 5, 2017 06:12
-
-
Save kidwai/0b2b2b76f59e3f369b94896d07bb1e66 to your computer and use it in GitHub Desktop.
scripts to set up a dank autominer with geth instead of testrpc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function automine (n) { | |
var n = n || 5; | |
setInterval(function () { | |
if (!eth.mining && (txpool.status.pending || txpool.status.queued)) { | |
console.log("miner start"); | |
miner.start(); | |
} | |
else if (eth.mining) { | |
console.log('miner stop'); | |
miner.stop(); | |
} | |
}, n*1000 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nonce": "0x0000000000000123", | |
"timestamp": "0x00", | |
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"extraData": "0x00", | |
"gasLimit": "0x8000000", | |
"difficulty": "0x10", | |
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"coinbase": "0x3333333333333333333333333333333333333333", | |
"config": {}, | |
"alloc": {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install geth if not already installed | |
if [ ! `which geth` ]; then | |
add-apt-repository ppa:ethereum/ethereum -y | |
apt-get update -y | |
apt-get install ethereum solc | |
fi | |
# initialize with this little genesis | |
geth init <(curl https://gist.githubusercontent.com/kidwai/0b2b2b76f59e3f369b94896d07bb1e66/raw/aa872739d886885d634abf61777c18399498180c/genesis.json) | |
# create an account with password "test" | |
geth account new --password <(echo "test") | |
# grab this autominer script (mines only when there are txs; keeps difficulty low for testing) | |
wget https://gist.githubusercontent.com/kidwai/0b2b2b76f59e3f369b94896d07bb1e66/raw/aa872739d886885d634abf61777c18399498180c/automine.js -O $HOME/.ethereum/automine.js | |
# add an alias to start this | |
echo "alias geth-test='geth --maxpeers 0 --nodiscover --unlock 0 --password <(echo test) --rpc console --preload $HOME/.ethereum/automine.js'" >> $HOME/.bash_aliases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment