Blockchain

 
 
A blockchain is a distributed database managed by a peer-to-peer network. The distributed database is also called a ledger which is a continuously growing chain of blocks. Each block contains a number of records and each block is linked to a previous block.

It is extremely difficult to change a record in any given block without the alteration of all subsequent blocks and the collusion of the network.

The first implementation of a blockchain was Bitcoin in 2009 invented by an unknown programmer, or a group of programmers, under the name Satoshi Nakamoto.

After the Bitcoin success many blockchain implementations followed such as Litecoin and Peercoin.

Other blockchain implementations introduces new kind of functionalities such as Ethereum and Dash.







Online Ethereum tools



Information
You need to have a running Ethereum node, for example testrpc
The RPC port of your locally running Ethereum node must be: http://localhost:8545

When starting your geth instance add the following parameter: --rpccorsdomain "*"

Running --rpccorsdomain="*" is a security risk, especially if you have unlocked accounts.
Put your domain name instead of *.
For localhost, add --rpcaddr="localhost"

Information about web3 api:
https://github.com/ethereum/wiki/wiki/JavaScript-API

Operating system used
macOS 10.12 Sierra

Software prerequisites
None



Tools

Description Files
Show all accounts on your running ethereum node.

Api used:
web3.eth.getAccounts()
ethereum_show_all_accounts.html
Show web3.version.n information

Api used:
web3.version.api
web3.version.ethereum
web3.version.network
web3.version.node
web3.version.whisper
ethereum_web3_version.html
Coinbase balance

API used:
web3.eth.coinbase
web3.eth.getBalance
web3.eth.filter
ethereum_balance.html
Ethereum contract

API used:
web3.eth.compile.solidity (Does not work on geth 1.6.0)
web3.eth.getBalance
web3.eth.filter
ethereum_contract.html
How to use bitcore-mnemonic and ethereum-bip44

ethereum-bip44
A module for bitcore that implements Mnemonic code for generating deterministic keys.

More information see:
https://www.npmjs.com/package/bitcore-mnemonic
https://github.com/bitpay/bitcore-mnemonic


ethereum-bip44
Library to generate Ethereum addresses from a hierarchical deterministic wallet according to the BIP44 standard. Internally it uses bitcore for the deterministic private and public keys which allows to use many additional features like deriving Ethereum address from mnemonic backups (BIP32).

More information see:
https://www.npmjs.com/package/ethereum-bip44
https://github.com/trapp/ethereum-bip44


bip44_mnemonic.html


As nodejs scripts:
bip44_mnemonic_example1.js.txt
bip44_mnemonic_example2.js.txt
Encode the constructor arguments in ABI hex form.
The output can be used for Contract Verification.
For contracts that accept constructor parameters, see:
https://etherscan.io/verifyContract

constructor_arguments_in_abi.js
Using web3 API with MetaMask.

web3api.html
Compile and deploy a single contract to blockchain

To interact with the smart contract you can use the DemoCombined.html web application.

deploy_contract.js
DemoCombined.sol
DemoCombined.html
Investigate the different solidity data types.
What are the max and min allowed values?

Types.sol.txt
Compile and deploy DemoContract.sol

To interact with the deployed DemoContract.sol contract you can use the DemoDapp.html web application.

Note:
Originally i have used callbacks in the DemoDapp.html, which resulted in annoying callback trees.
I have refactored the code but now using JavaScript Promises.

For educational purpose here is the "callback version": DemoDappv0.1.html

DemoContract.sol
DemoDapp.html
Proof of concept how to store signatures in a smart contract.

SignatureStorage.html
SignatureStorage.sol.txt
ACMEContract.doc
ACMEContract.pdf