These instructions will allow you to get a ethereum dev network up and running on your local machine for development and testing purposes.
Install Command
npm install -g ethereumjs-testrpc
Start testrpc command
$ testrpc --port 8545
testrpc: https://github.com/ethereumjs/testrpc
- Installing Ethereum client
For Ubuntu
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
Check version
$ geth version
Other Operating systems: https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum
It will create a directory where all the chain data including wallet keys will be stored.
$ sudo mkdir dev
This command will create new Ethereum Account keystore at .../dev/keystore/
and store the keys in the keystore directory.
Default directory = /root/.ethereum/keystore/
$ geth --datadir 'dev' account new
Passphrase: xxxxxxxx
Repeat passphrase: xxxxxxxx
Address: {4e6cf0ed2d8bbf1fbbc9f2a100602ceba4bf1319}
Copy the displayed account address
This command will start the Ethereum client process.
$ sudo geth --datadir="dev" --dev --etherbase="0x0000000000000000000000000000000000000000" --unlock 0 console
-- dev flag - to use the pre-configured settings provided by geth.
-- etherbase flag - set miner account.
--datadir flag - set the location of chain data
--unlock - keep account unlocked for the session. 0 - account [0]
Enter the passphrase to unlock the wallet
This command will start the miner process.
miner.start()
Check current balance in Wei
web3.eth.getBalance(eth.accounts[0])
Check current balance in Ethers
web3.fromWei(web3.eth.getBalance(eth.accounts[0]),'ether')
This command will allow you to connect your Ethereum client from external device on same network. --rpc start rpc server.This is generally enabled by default in Geth.
--rpcport select rpc port. Default port is 8545
--rpcaddr "0.0.0.0" '(Not Safe)'
--rpccorsdomain specify URLs which can connect to your node in order to perform RPC client tasks '(Not Safe)'
Add to start command
--rpc --rpcaddr "0.0.0.0" --rpcport 8546 --rpccorsdomain "*" --rpcapi "db,eth,net,web3,personal"
OR
admin.startRPC("0.0.0.0", 8546, "*", "web3,net,eth")
admin.stopRPC()
sample:
$ sudo geth --datadir="dev" --dev --rpc --rpcaddr "0.0.0.0" --rpcport 8546 --rpccorsdomain "*" --etherbase="0x0000000000000000000000000000000000000000" --nodiscover --unlock 0 console