The following will walk you step-by-step to setup a Wethio private net with three Masternodes.
Reference: https://golang.org/doc/install​
Set environment variables
set GOROOT=$HOME/usr/local/goset GOPATH=$HOME/go
cd $GOPATH/src/github.com/ethereum/go-ethereum
Download source code and build
git init<!-- git remote add git@github.com:tomochain/tomochain.git -->git pull origin mastermake all
Create shortcuts/alias for easier access
alias zyn=$GOPATH/src/github.com/ethereum/go-ethereum/build/bin/zynalias bootnode=$GOPATH/src/github.com/ethereum/go-ethereum/build/bin/bootnodealias puppeth=$GOPATH/src/github.com/ethereum/go-ethereum/build/bin/puppeth
mkdir $HOME/wethiomkdir $HOME/wethio/nodesmkdir $HOME/wethio/nodes/1 $HOME/wethio/nodes/2 $HOME/wethio/nodes/3mkdir $HOME/wethio/keystore/1 $HOME/wethio/keystore/2 $HOME/wethio/keystore/3
Initialize new accounts: If there are existing accounts and a preference to import them, please ignore this step and go to Import Accounts
zyn account new \--password [YOUR_PASSWORD_FILE_TO_LOCK_YOUR_ACCOUNT] \--keystore $HOME/wethio/keystore/1
zyn account new \--password [YOUR_PASSWORD_FILE_TO_LOCK_YOUR_ACCOUNT] \--keystore $HOME/wethio/keystore/2
zyn account new \--password [YOUR_PASSWORD_FILE_TO_LOCK_YOUR_ACCOUNT] \--keystore $HOME/wethio/keystore/3
Import accounts
zyn account import [PRIVATE_KEY_FILE_OF_YOUR_ACCOUNT] \--keystore $HOME/wethio/keystore/1 \--password [YOUR_PASSWORD_FILE_TO_LOCK_YOUR_ACCOUNT]
Repeat this step to import two more private keys for our three masternodes.
Run puppeth command and answer questions about your private chain as follows:
puppeth
Set chain name
> local
Enter 2 to configure new genesis
Enter 3 to select POSV
consensus
Set blocktime (default 2 seconds)
Set reward of each epoch
Set addresses to be initial masternodes
Set number of blocks of each epoch (default 900). If you would like to customize epoch number, please update code here common/constants.go:14
EpocBlockRandomize = 900
Set gap (How many blocks before checkpoint need prepare new masternodes set ?)suggestedGap = 5
Enter foundation address which you hold private key
Enter accounts which you control private keys to unlock MultiSig wallet
Enter swap wallet address for fund 55 million ZYN
Export genesis file - Select 2. Manage existing genesis
- Select 2. Export genesis configuration
- Enter genesis filename
Control + C
to exit
zyn --datadir $HOME/wethio/nodes/1 init [PATH/TO/GENESIS_FILE]zyn --datadir $HOME/wethio/nodes/2 init [PATH/TO/GENESIS_FILE]zyn --datadir $HOME/wethio/nodes/3 init [PATH/TO/GENESIS_FILE]
Initialize bootnode key
bootnode -genkey bootnode.key
Start bootnode and copy bootnode information
bootnode -nodekey ./bootnode.key
enode://7e59324b1e54f8c282719465eb96786fb3a04a0265deee2cdb0f62e912337ca
6f118d0c91f7ebfae6f5c17825205279249cf7ff65ae54d0a1a8908ef16f80f63@[::]:30301
Start Masternode 1
zyn --syncmode "full" \--datadir $HOME/wethio/nodes/1 --networkid [YOUR_NETWORK_ID] --port 10303 \--keystore $HOME/wethio/keystore/1 --password [YOUR_PASSWORD_FILE_TO_UNLOCK_YOUR_ACCOUNT] \--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 1545 --rpcvhosts "*" \--rpcapi "db,eth,net,web3,personal,debug" \--gcmode "archive" \--ws --wsaddr 0.0.0.0 --wsport 1546 --wsorigins "*" --unlock "[ADDRESS_MASTERNODE_1]" \--identity "NODE1" \--mine --gasprice 2500 \--bootnodes [YOUR_BOOTNODE_INFORMATION] \console
Start Masternode 2
zyn --syncmode "full" \--datadir $HOME/wethio/nodes/2 --networkid [YOUR_NETWORK_ID] --port 20303 \--keystore $HOME/wethio/keystore/2 --password [YOUR_PASSWORD_FILE_TO_UNLOCK_YOUR_ACCOUNT] \--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 2545 --rpcvhosts "*" \--rpcapi "db,eth,net,web3,personal,debug" \--gcmode "archive" \--ws --wsaddr 0.0.0.0 --wsport 2546 --wsorigins "*" --unlock "[ADDRESS_MASTERNODE_2]" \--identity "NODE2" \--mine --gasprice 2500 \--bootnodes [YOUR_BOOTNODE_INFORMATION] \console
Start Masternode 3
zyn --syncmode "full" \--datadir $HOME/wethio/nodes/3 --networkid [YOUR_NETWORK_ID] --port 30303 \--keystore $HOME/wethio/keystore/3 --password [YOUR_PASSWORD_FILE_TO_UNLOCK_YOUR_ACCOUNT] \--rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 --rpcport 3545 --rpcvhosts "*" \--rpcapi "db,eth,net,web3,personal,debug" \--gcmode "archive" \--ws --wsaddr 0.0.0.0 --wsport 3546 --wsorigins "*" --unlock "[ADDRESS_MASTERNODE_3]" \--identity "NODE3" \--mine --gasprice 2500 \--bootnodes [YOUR_BOOTNODE_INFORMATION] \console
Some explanations on the flags
--verbosity: log level from 1 to 5. Here we're using 4 for debug messages--datadir: path to your data directory created above.--keystore: path to your account's keystore created above.--identity: your full-node's name.--password: your account's password.--networkid: our testnet network ID.--port: your full-node's listening port (default to 30303)--rpc, --rpccorsdomain, --rpcaddr, --rpcport, --rpcvhosts: your full-node will accept RPC requests at 8545 TCP.--ws, --wsaddr, --wsport, --wsorigins: your full-node will accept Websocket requests at 8546 TCP.--mine: your full-node wants to register to be a candidate for masternode selection.--gasprice: Minimal gas price to accept for mining a transaction.--targetgaslimit: Target gas limit sets the artificial target gas floor for the blocks to mine (default: 4712388)--bootnode: bootnode information to help to discover other nodes in the network--gcmode: blockchain garbage collection mode ("full", "archive")
To see all flags usage
zyn --help
Connect ipc
zyn attach $HOME/wethio/nodes/1/zyn.ipc
admin.nodeInfoeth.getBlock(0)eth.getBlock(1)
Connect rpc
zyn attach http://localhost:1545
eth.getBlock(0)eth.getBlock(1)
Verify Checkpoints
Wait about 30 minutes to see if your chain passes the first checkpoint
zyn attach http://0.0.0.0:1545
eth.getBlock(900)
Reset your chain
rm -rf $HOME/wethio/nodes/1/zyn $HOME/wethio/nodes/2/zyn $HOME/wethio/nodes/3/zynzyn --datadir $HOME/wethio/nodes/1 init genesis.jsonzyn --datadir $HOME/wethio/nodes/2 init genesis.jsonzyn --datadir $HOME/wethio/nodes/3 init genesis.json
Note: we use the Gnosis Multisig Wallet: https://github.com/gnosis/MultiSigWallet​