- Software Installation and Startup Guide
- 1. Node.js
- 2. Ethereum Blockchain Client (Command Line Interface)
- 3. DC Energy Meter Drivers
- 4. Arduino IDE
- 5. Smart Contract Deployment
Download Node.js for your respective Operating System from here. (This project requires Node.js v6+ to run.) Open your favorite Terminal and run these commands.
- Check Node version.
$ node -v
- Check Node Package Manager Version.
$ npm -v
- Now that you have Node set up on your machine, you need some extra Node Modules installed before you move ahead to install the Blockchain Client.
$ npm install express --save $ npm install socket.io --save $ npm install web3 --save $ npm install web3admin --save
Open a terminal from within the cloned package directory and run the following commands.
-
Geth Installation (Go-Ethereum) For Ubuntu
$ tar -xvf Softwares/Ethereum_Go_Lang/geth-linux-amd64-1.5.8-f58fb322.tar.gz $ mv geth-linux-amd64-1.5.8-f58fb322 Geth
For MacOS
$ tar -xvf Softwares/Ethereum_Go_Lang/geth-alltools-darwin-amd64-1.5.8-f58fb322.tar.gz $ mv geth-alltools-darwin-amd64-1.5.8-f58fb322 Geth
-
Geth Initialization Create a Private Network with a custom genesis block provided to you.
This command will output "Successfully wrote genesis block" on the console.$ ./Geth/geth init genesis.json
To start the geth CLI console enter the following command.
$ ./Geth/geth --rpc --rpcapi="eth,web3,miner,net,personal" --rpcaddr="localhost" --rpcport="8545" --rpccorsdomain="*" console
Now you will have entered the ethereum console, where you can type geth commands on lines that start with this:
>
-
Geth Basic Commands The following commands can be given to the ethereum console. a. Create a new account (Remember the passphrase of each new account created along with its hexadecimal address).
> personal.newAccount("your_passphrase") [output] "0x........................................"
b. Show all account addresses
> eth.accounts [output] ["0x........................................"]
c. Show a particular account address
> eth.accounts[0] [output] "0x........................................"
d. Check account balance in Ether
> eth.getBalance(eth.accounts[0]) [output] 0
e. Make transaction from one account to another. Enter the correct passphrase to unlock the account from which you are sending Ether.
> personal.unlockAccount(eth.accounts[0]) [output] passphrase: Type Passphrase here [output] 'True' / 'False' > eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: 1234}) [output] Transaction ID
f. Mining operations
> miner.start() [output] "Mined potential block with 'x' transactions" > miner.stop()
g. Retrieve blockchain personal node information
> admin.nodeInfo [output] coinbase [output] enode [output] block number [output] difficulty
h. Exit console
> exit
-
Connecting two users on the same private network Ensure that both the users are on the same local network and are initialized with the same genesis.json file.
Exchange the enode data of both users from theadmin.nodeInfo
command output.
Add a peer using the exchanged enodes by the following command.> admin.addPeer("enode://other_users_enode_hex@other_users_ip_address:30303") [output] 'True' / 'False' > net.peerCount [output] 1 if both are connected successfully else 0
Once connected, you will see
Block Syncronization Started
on console. -
Allocate Ether to your accounts in
genesis.json
file.
By default, every account created in the private network has zero balance. To generate Ether, one needs to mine for long period of time or else, one can edit thegenesis.json
file to allocate a starting balance to any account id.To allocate a starting balance, add the following lines in the genesis.json file.
"alloc": { "Account_address_in_hexadecimal": {"balance" : "Enter_value_in_Ether"}, "Account_address_in_hexadecimal": {"balance" : "Enter_value_in_Ether"}, "Account_address_in_hexadecimal": {"balance" : "Enter_value_in_Ether"} }
Save this edited file. Now re-initialize the geth node with this edited genesis data using the same command as mentioned previously.
Remeber that when connecting multiple users on same blockchain network, all users need to initialize their geth node with the same
genesis.json
file.
-
Install the USB Serial port drivers for retrieving data from the Everon DC Energy Meters.
-
.exe installation files are provided in the
Softwares/DC_Energy_Meter/
folder in compressed format. -
Any RS232 serial port driver will work in case .exe files are not supported on your OS.
-
Install the suitable version of Arduino IDE for your OS from here.
-
This is required to program and control the custom made relay circuit using Arduino Nano fitted inside the energy meter to control the conn
- Read this to learn how to deploy a smart contract on your private network.