Secure Smart Contract Tools — An End-to-End Developer’s Guide

Michael Bogan
Level Up Coding
Published in
7 min readDec 12, 2022

--

No doubt — writing secure smart contracts is hard. Even smart contracts written by senior developers can get hacked. And since these smart contracts often hold a high monetary value, the incentive to hack them is also high. Add in the immutability of web3, and getting security right becomes even more important. As a smart contract developer, smart contract security should be your top priority.

In this article, I will walk through a recently published guide, Security Tooling Guide for Smart Contracts by ConsenSys Diligence. It details 22 security tools from across web3 available at each stage of smart contract development. I’ll highlight several important tools to help make your next smart contract even more secure.

So let’s walk through the guide one development stage at a time.

Preparing for Development

As you begin developing your smart contracts, security should be top-of-mind. My favorite sections of the guide are the tools that can help even as you prepare to code. This includes documentation, linting, and writing reusable code.

First, documentation is key to any development project, and smart contract development is no exception. The Ethereum Natural Specification Format (NatSpec) is a great way to document smart contracts.

NatSpec is a special form of comments added to provide rich documentation for contracts, interfaces, libraries, functions, and events. Consider the following solidity code snippet for a Tree Contract:

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 < 0.9.0;
/// @title A simulator for trees
/// @author Larry A. Gardner
/// @notice You can use this contract for only the most basic simulation
contract Tree {
/// @notice Calculate tree age in years, rounded up, for live trees
/// @dev The Alexandr N. Tetearing algorithm could increase precision
/// @param rings The number of rings from dendrochronological sample
/// @return Age in years, rounded up for partial years
function age(uint256 rings) external virtual pure returns (uint256) {
return rings + 1;
}
}

NatSpec commented Solidity Contract

By making use of NatSpec annotations, code can be easily explained to other developers, auditors, or someone just looking to interact with the contract. Simply put, it is clean, readable, and easy…

--

--

25 years of startups, products, and software architecture. Currently run DevSpotlight — tech content for tech companies. michael@devspotlight.com.