This project was generated with Angular CLI version 1.3.0.
An angular2 + truffle starter app. Write, compile & deploy smart contracts for Ethereum.
First, download the project locally on your computer.
To successfully run this project two parts need to be configured: the front-end + middleware and the back-end.
- Access the folder
cd network-slicing-prototype
. - Install all the packages and dependencies needed in the project
npm install
. - Run front-end
npm start
, which starts the application in locahost. The app will automatically reload if you change any of the source files. - Open a new tab and in the same folder, run
gulp serve
to execute the middleware in port 3001.
For the second part, we will use GETH to build our own private chain. After having defined the genesis file genesis.json, one Ethereum node must build the blockchain, by executing the following commands:
- Install Geth
- Go to to the geth folder
cd geth
. - To initialize the node with the defined genesis block in the specified data directory
geth --datadir <path-to-directory> init genesis.json
- Run the node from the previous created data directory. More information on the meaning of each command line parameter can be found here Go-ethereum.
geth --port 3000 --networkid 58342 --datadir="<path-to-directory>" --maxpeers=3 --rpc --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "http://localhost:8000" --rpcapi "eth,net,web3,personal" --gasprice "0" --nodiscover console
. - Create a mining address and unlock it.
personal.newAccount('password')
web3.personal.unlockAccount(web3.personal.listAccounts[0],"password", 0)
.
To create multiple clients into the blockchain this process should be repeated for the different actors. Thus, after executing these commands for each of the Ethereum clients, which should have the same genesis file and network ID but different domains, ports and data directories, these nodes need to be synchronized. To achieve this, Geth supports a feature called static nodes, which can be configured into \textit{/static-nodes.json}. These static nodes are added through the so-called \textbf{Enodes}, which are Ethereum nodes written in a URL scheme.
In our project, we have locally defined 5 clients privchain1, ..., privchain5, which perform the mining together. In addition, we run these clients with an extra parameter in command 4 --preload "poetSimulation.js"
, which allow us to simulate the Proof of Elapsed Time (PoET) consensus protocol by preloading a Javascript file. In order to reduce the mining time, we establish an almost negligible difficulty with a fixed value from the beginning. To achieve this, we have modified a file from the open source code of Ethereum that defines the PoW consensus model (go-ethereum-master/consensus/ethash/consensus.go). Specifically, the CalcDifficulty function (line 2 in Listing \ref{lst:tailorPow}) now returns 0x400, which is the hexadecimal value of 1024. Thus, command 4 needs to be started with the modified version of GETH.
If a contract is modified, it should be compiled and uploaded on the blockchain.
truffle compile
to compile your contracts.truffle migrate
to deploy those contracts to the BC.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
You can also contact me by: jordi.bisbalansaldo@stud.tu-darmstadt.de
- Angular2 (HTML/Typescript)
- Node.js
- Truffle
- Web3.js
- GETH
- Solidity