Deploy your Truffle smart contracts to the Live Network

You finished building your contract using the Truffle Framework and are done testing it on the test RPC and are ready to put it on the Ethereum main net to share it to the world? In this tutorial, we’ll cover what you need to deploy a contract to the Ethereum blockchain.

Setting Up Your Ethereum client

There are many Ethereum clients to choose from. The most popular are go-ethereum and cpp-ethereum. We’ll not cover how to install and configure the client as lot of documentation is available on the clients project page.

To deploy your contract to the blockchain you need that:

  • Your client is completely downloaded the blockchain data.
  • Your client is hosting an RPC server on localhost and is accessible by a port, for example: 8546
  • Your client has at least one account registered and have the rights to sign transactions for that account
  • The registered account contains enough Ethereum to deploy your contracts

Setting up your Truffle project

The next step is to tell Truffle how to communicate with our client. For this we will open and edit the truffle.js file at the root of your project. In the network array, we will add the information of our live configuration which specifies the name of the network, the port and the address used to communicate with the client.

Save the file and we are now ready to deploy our project to the blockchain.

Deploying your smart contract

To deploy your smart contract, just open your terminal and type:

Truffle will run the command and will use your client registered address to publish the smart contract to the Ethereum blockchain.

Once your contract will be compiled and deployed, the address of the deployed contracts will be printed on your console. You can also find the address in the json files located in the build/contracts/YOUR_CONTRACT_NAME.json .


If you’re looking for people to thrust your contracts, it might be important to share and verify your contract code on Etherscan webiste.




Verify your Truffle compiled and deployed contract on Etherscan

When asking users to thrust your smart contract code it may be important to share the code of the contract with them. Linking to the project source code from Github may not be enough as there is no guarantee that the code you show is the same as the code that runs your smart contract. You can see a list of verified smart contracts on

First of all, once you published you smart contract to the main net or any test network you need to find it on Etherscan by using the search field.

Once on your smart contract page, navigate to the Contract code  tab and click on Verify and publish .

As the truffle framework optimize your contract, you’ll need to verify your contract source code in the new interface by clicking new Beta Source Code Contract Verifier .

You will then need to enter the name of your contract. The name must exactly match the one in your source code.

Then select the version of your Solidity compiler. If you are not sure about which version you are running, you can get it by typing solc --version  in your terminal.

You then need to paste the code of your contract in the code text box. At this point, if you have any import  you will need to manually remove them and copy and paste the content of the file instead of the import  statement. If you want to go faster, you may check Blockcat solidity-flattener, a tool that will automatically concatenate the files for you.

If you deployed a contract which contained constructor arguments, you’ll need to add them in the following input box. Constructor arguments are expected to be ABI-encoded. More information on ABI-encoding can be found on the page, but remember that the constructor arguments are written right to left.

In the additional parameters section, you should check the number of times the optimizer is runt. For contracts compiled with Truffle, the correct default value for runs is 0.