Skip to content

katopz/ethereum-docker

 
 

Repository files navigation

Ethereum Docker

Get started creating Ethereum development and test single and multi-node clusters rapidly using Docker.

We provide full Ethereum test nodes (using the Ethereum Go client with all APIs enabled by default as well as a monitoring dashboard (for the cluster version) provided via Netstats.

Alternative projects

TestRPC - https://github.com/ethereumjs/testrpc

Getting started

1. Installing

1.1. Standalone Ethereum node

Prerequisites

Docker Toolbox installed.

To download and install Docker Toolbox for your environment please follow the Docker Toolbox instructions.

After Docker Toolbox has been installed, create a default machine to run Docker against.

Lets go

To run a single test Ethereum node run the following:

$ docker-compose -f docker-compose-standalone.yml up -d

If using docker-machine you should be able to get to the JSON RPC client by doing:

open http://$(docker-machine ip default):8545

Assuming you ran docker-compose against the default machine.

1.2. Ethereum Cluster with netstats monitoring

To run an Ethereum Docker cluster run the following:

$ docker-compose up -d

By default this will create:

  • 1 Ethereum Bootstrapped container
  • 1 Ethereum container (which connects to the bootstrapped container on launch)
  • 1 Netstats container (with a Web UI to view activity in the cluster)

To access the Netstats Web UI:

open http://$(docker-machine ip default):3000

Scaling the number of nodes/containers in the cluster

You can scale the number of Ethereum nodes by running:

docker-compose scale eth=3

This will scale the number of Ethereum nodes upwards (replace 3 with however many nodes you prefer). These nodes will connect to the P2P network (via the bootstrap node) by default.

1.3. Test accounts ready for use

As part of the bootstrapping process we bootstrap 10 Ethereum accounts for use pre-filled with 20 Ether for use in transactions by default.

If you want to change the amount of Ether for those accounts See files/genesis.json.

2. Interact with geth

To get attached to the geth JavaScript console on the node you can run the following

docker exec -it ethereumdocker_eth_1 geth attach ipc://root/.ethereum/devchain/geth.ipc

Then you can miner.start(), and then check to see if it's mining by inspecting web3.eth.mining.

See the Javascript Runtime docs for more.

2.1 Use an existing DAG

To speed up the process, you can use a pre-generated DAG. All you need to do is add something like this

ADD dag/full-R23-0000000000000000 /root/.ethash/full-R23-0000000000000000

to the monitored-geth-client Dockerfile.

Extras

Do everything with npm

To run ethereum

npm run up

To open netstats

open http://localhost:3000

To turn off ethereum

npm run down

Create new accounts

# On Main network
npm run new

# On testnet network
npm run new-testnet

# On Dev network
npm run new-dev

List accounts

# On Main network
npm run ls

# On testnet network
npm run ls-testnet

# On Dev network
npm run ls-dev

Mining

# On Main network
npm run mine

# On testnet network
npm run mine-testnet

# On Dev network
npm run mine-dev

Develop

To get in console

# On Main network
npm run console

# On testnet network
npm run console-testnet

# On Dev network
npm run console-dev

To attach

npm run attach

To get balance

# For account ID=0 you can just
npm run balance

# Or by run script directly
npm run exec -- 'eth.getBalance( eth.accounts[0] )'

# Or use variable ID=0
ID=0 npm run balance

# And for ID=1
ID=1 npm run balance

To run external javascript file

# Use loadScript
npm run exec -- 'loadScript("/src/helloworld.js")'

# Or just load
JS=./src/helloworld.js npm run load

About

Ethereum development and test single and multi-node clusters using Docker 🐳

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 63.2%
  • Shell 36.8%