So far we have built our GreatestShow smart contract, but we have not even run it locally. Let’s do that for a second. Open up a console window in the base of your project and run the simulator for a blockchain, called testrpc . TestRPC

testrpc is a Node.js based Ethereum client for testing and development. It uses ethereumjs to simulate full client behavior and make developing Ethereum applications much faster. It also includes all popular RPC functions and features (like events) and can be run deterministically to make development a breeze.

Be sure that you have installed testrpc on the command line.

npm install -g ethereumjs-testrpc

Then, fire up an instance of testrpc , which is a great way of running a test blockchain that adheres to the Ethereum protocol while simulated mining, so making function calls and submitting transactions is fast and efficient. Accounts can be re-used and reset. Not to be used for production, but definitely used in the development & test stages.

testrpc -m “warrior minimum breeze raven garden express solar flavor obvious twenty alpha actress”

Starting testrpc with the -m flag allows you to specify a 12 word mnemonic, for which all of the accounts generated by the program will use as its seed for creating private keys and account addresses. This is a detail we’ll skip over for now, but just no that using the same mnemonic each time we start allows us to deterministically know what accounts will be created. Once the process is running, we’ll know because we will have output that looks similar to this list of 10 available accounts, and their private keys.

Now that we have a simulated blockchain running on our localhost on port 8545, clients can connect to it. Our first client will be the truffle console that is included as a part of the truffle framework. Go ahead and open a new tab and start the console.

truffle console

You’ll be prompted with a scary looking error. Don’t worry.

No network available. Use `truffle develop` or add network to truffle.js config.

Don’t bother using truffle develop as the message suggests, because we need to complete this step in order to proceed with connecting other networks in the future. This is a necessary step to understand how to connect to other networks.

Open up your editor (I’m using sublime, so I can type subl . at the prompt.

Open a file called truffle.js at the root of your configuration. Let’s define three different networks: development , ropsten , and mainnet . We’ll fill in the details for ropsten and mainnet later. Let’s just get this rolling with development for now. I like to keep the gas limit as close to the ropsten test network as possible, but that’s just a personal preference that has some practical purposes as well. I can guarantee my contracts never require the limits of the test network, which at this time are lower than mainnet . Stay under this limit and you’re golden for production as well.

let ropstenProvider, mainNetProvider; module.exports = {

networks: {

development: { host: "localhost", port: 8545,

network_id: "*", gas: 4465030 },

ropsten: { provider: ropstenProvider,

network_id: "3", gas: 4465030 },

mainnet: { provider: mainNetProvider,

network_id: "1", gas: 7500000 }

}

};