Artur Chmaro

blog about web technologies

Setup local Ethereum node for development

To experiment a bit with Ethereum you need access to the network. Starting with mainnet (production network) is not a wise idea for the beginners. First of all, you have to pay real money (gas) for it. Secondly, each transaction takes time to be mined. Both issues can be easily solved by running your own blockchain on your computer. All you need is node and ganache-cli package installed globally into your system (Windows, Mac, Linux).

Install ganache-cli globally in your system and than launch it:

npm -g ganache-cli
ganache-cli



Now you can start interacting with your blockchain using MetaMask wallet or any other software that connects to the blockchain via RPC. By running ganache-cli without any parameters, all your transactions will disappear once you terminate the program. It might be useful to keep your blockchain transactions at the hard drive. Recreating smart contracts or repeating operations each time you rerun ganache-cli might be painful.

To save your time, use the following command:

ganache-cli -d -m 'some long word phrase' --db mydata



-d -m ensures that each time ganache creates the very same subset of accounts. --db mydata creates a directory with given name and stores all blockchain data there. Such command is handy for local tests because you do not need to import new accounts to your wallet every time you start ganache. To each of my projects, I'm adding npm script, so I do not have to type this command every single time. Something like npm run ganache is more comfortable to remember and type.

Ganache is not the only option to take, but probably the easiest one. You can also give a try to Geth, Parity, or Quorum.