Press Ctrl+X, Y, Enter to save your new genesis block.
Create your blockchain
Run the following commands to create a blockchain (the maxpeers option is set to 0 in order to disable the network):
geth --datadir eth-new genesis.json init eth-new/genesis.json --networkid 123 --nodiscover --maxpeers 0 console
To make a new account and password type the following in the geth console (don't forget to specify login data in brackets). Oh, there's one more thing: you'll have to specify your new password twice:
The output after this should be a string of letters and numbers, i.e. an address of your account. To stay on the safe side, save the address specified somewhere else and exit (type "exit" and press Enter).
Send some ETH to your newly created account
Open the genesis block file once again and type the following:
Copy previously saved account address and paste it into the "alloc" brackets. Next, go ahead and give yourself an ETH balance. The amount shown next to "balance" below is equal to 10 ETH. Once you are done with making changes, save the file with Ctrl+X, Y, Enter.
Delete an old blockchain and create a fresh one. Use these commands to get rid of the old blockchain data and restart geth:
rm -rf chaindata dapp history nodekey
geth --datadir eth-new genesis.json --networkid 123 --nodiscover --maxpeers 0 console
In the geth console, type the following:
> primary = eth.accounts
> web3.fromWei(eth.getBalance(primary), "ether")
As a result, you get a new address and balance of 10 ETH.
To get yourself a full-fledged blockchain, you need to develop miners. To cope with this challenges, close the geth console (type "exit" + hit Enter).
Run the following command to start mining:
geth --mine --datadir eth-data --networkid 123 --nodiscover --> maxpeers 0 console 2>>geth.log
Congrats! You’ve just created your very own miner capable to collect ETH fees. If you want to check your cryptocurrency balance, run the following command:
> primary = eth.accounts
> balance = web3.fromWei(eth.getBalance(primary), "ether")
Install the Solidity Compiler
Just like other cryptocurrencies, the Ethereum uses the advantage of smart contracts written in Solidity. So, to use that contract-oriented programming language, you need to install the Solidity Compiler. To do this, type the following lines in a new terminal:
sudo add-apt-repository ppa:ethereum/ethereum
After getting a message: "Press ENTER to continue" press Enter and type the following:
sudo apt-get update
sudo apt-get install solc -y
This will provide a path to Solc that you'll need to remember. Now, return to the terminal window showing the geth console. Run the following commands, changing to the path value you got:
If you get ["Solidity"] as a response to the second command, it means, you got yourself the Solidity Compiler and can write in Solidity.
Difference between mortal and greeter contracts
Below is the code for a simple contract with added comments. It contains two types of contracts:
a mortal contract that can be killed by the person who wrote it and it needs to be declared as such, as contracts are immortal by default;
a greeter contract that is nothing but a "Hello World!" greeting.