Dockerized Private Ethereum Testnet
Start by installing Docker in your local system to host the testnet container.
Start by pulling the Ethereum Go Client image
docker pull ethereum/client-go
docker run -it -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rpcaddr "0.0.0.0"
Store the blockchain data on a persistent volume.
docker run -it -p 30303:30303 -v /path/on/host:/root/.ethereum ethereum/client-go
Setting up Ganache can be beneficial when you need to run a localized version of the Ethereum Blockchain. Truffle Framework provides the installer for your platform which you can download here; Ganache.
Once installed you can run the binary to start the blockchain interface http://127.0.0.1:7545, when you run the first time it will create 10 test ethereum accounts with 100.00 ether available to spend.
Interacting with the Ethereum Blockchain is done with Web3 by creating an instance of the web3 client.
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers, 8545 for Ethereum Testnet / 7545 for Ganache Testnet
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
}
Once the provider is initialized you can begin to call methods on the web3 interface.
const coinbase = web3.eth.coinbase;
const balance = web3.eth.getBalance(coinbase);