How do I make sure that a smart contract is production ready. Other than unit testing, what other methods or tools are currently available ?


Functional testing is only the first step before deploying your contract to MainNet. Once your contract is doing what you want it to do, you'll want to pay close attention to the following:

  • Security (very important)
  • Optimization
  • Upgradeability

I've put some high level information about each below, but each topic is very involved, so you'll have to do some additional research on your own to learn more.


Security flaws in your contract will make it unusable. You need to protect access to your contract, prevent re-entrancy, perform safe math operations, and make sure your contract has emergency fail-safes in case an issue is discovered after deployment.

The Solidity docs have several pointers to help deal with this. There are also security tools that can analyze your code such as Oyente, SmartCheck, Mythril and several others. See this post on Ethereum StackExchange for more suggestions


Optimizing your contracts will help to minimize gas usage resulting in both cost benefits and protects against out of gas exceptions. Are you only storing data that needs to be stored? Are you using the correctly sized data types and ordering the elements of your structs to be tightly packed? Most importantly, are you avoiding expensive loops (or, even worse, nested loops) that can perform an unknown number of iterations?

Look for areas where you can limit code execution, remove loops, short circuit condition checks, etc. There is a well-written paper on smart contract optimization that can be found here.


Finally, what will you do if you need to release a new version of your contract? If the data your contract relies on is tightly coupled with the business logic of your contract, you will have to migrate all of that data when your business logic changes. That's very costly. Ideally, you'll want to put your data into its own external storage contract that implements an interface, and use that interface to interact with your data from within your business contract.

Here is a blog post that goes into more detail on writing upgradeable contracts and goes through an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.