Tutorial for setting up an Ethereum private chain, sending transactions, and doing smart contracts ...
This tutorial was tested on Ubuntu 16.04. Test on CentOS 7.0 were unsuccessful because of the lack of the solidity compiler for CentOS.
- Install the OS and fix it.
- Disable the firewall and install OpenSSH server (apt-get install openssh-server)
- Install git (apt-get install git)
- Clone this repository.
- cd to ethereum-private-chain dir
- run ./install_ethereum_environment.sh
Ethereum is one of many existing blockchains, e.g. Bitcoin, Litecoin, Ripple etc. The reason why I choose Ethereum is that it provides an open development and testing environment (in my case geth) and it provides a varity of access protocols and languages, e.g. JavaScript, Rest, RMI, etc. Additionally Ethereum is the only blockchain I know, which provides so called "smart contracts".
The purpose of this project is to provide an easy to setup access point for interacting with our IntegrationServer. Follow up projects can use this project as a basis for e.g. create a smart contract and monitor the behavior of this contract in a BPM process.
Running the script init_geth.sh will generate the genesis block for the private chain and assign suffient ether to the predefined account[0]. The datadir and log dir is created. Several geth consoles can now be started to work together based on this block chain.
Running the command run_geth_console will start the cli for Ethereum. This script will also start mining. The outputs of the console should be "tailed" in an additional command shell located in logsdir/.log.
In a third shell the ethereum action is triggered by running exec_geth_jsscript.sh with the filename of the appropriated action, in this case doATransaction.js.
The result of this action is the transmission of ether from account[0]-wallet to account[1]-wallet. By specifying "eth.fromWei(eth.getBalance(eth.account[1]), ether");" in geth cli before and after the transmission of ether, the increase of ether for account[1] can be monitored.
Contracts are written in a language called "solidity" (beside solidity there are currently 2 other languages to describe a contract). The solidity contract greeter.sol is converted via generate_contract.sh into the file greeter.js. You can run the greeter.js from within geth.
- Create or download a valid solidity contract file.
- Run generate_contract .sol
- Edit the auto-generated .js and adjust the settings (explaination see inside the file)
- In geth run 'loadScript(".js")'. Don't forget the quotes!!!
- Wait for the ethereum mining completed message.
To connect a geth node to an existing node it's crucial that the genesis blocks have the same hash value (use "init" option to handle this), and you can telnet rpc ports on both machines. Use admin.addPeer(...) to connect and admin.peers to query connection.
A good tool for testing seems to be Remix. The cloning address for github is: git clone https://github.com/ethereum/browser-solidity
not known
These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
Contact us at TECHcommunity if you have any questions.