Get (re)Started with building on Ethereum

Chris Whinfrey wrote a great tutorial on getting started with Ethereum.  It took me less than an hour to download all the tools and run the test project that comes with Truffle. I created my own private blockchain running via testrpc, 10 wallets filled with 100 ether, and even 10,000 shiny MetaCoins! I could view them all via my MetaMask Chrome plug-in.

I turned off my computer, and went to bed.

Two days later, everything was gone. My ether evaporated and my dApp couldn't even check my MetaCoin balance.

This is a tutorial on how to get re-started with building on Ethereum.

First, you need to restart your private blockchain and seed it with the same accounts you had before (and have conveniently saved into MetaMask). The trick is to use a mnemonic to start testrpc.  The mnemonic lets you restart the blockchain with the same accounts, preloaded with 100 ether. Hopefully, you saved the output of your first testrpc run - it will include the HD Wallet mnemonic. 

testrpc --mnemonic="my special words that I saved"

What?! You didn't save the mnemonic from the first time you ran testrpc? That's ok. MetaMask still has the private keys for all your accounts. You can manually specify each account's private key and balance.

testrpc --account="7ba30c70faa34ca7032d7d0e17112345d7c2950f8063196d0488818881cab1ce,100" 

Now you need to push your MetaCoin contract to your private blockchain. Remember - testrpc starts with a clean blockchain. Go to your MetaCoin directory and type:

truffle migrate

Finally, you can run your dApp

npm run dev

Open up Chrome and go to http://localhost:8080. MetaMask should show that all your accounts have a balance of 100 ether, and you should have 10,000 MetaCoins again.