How to do it...

  1. One of the popular static analysis tools in the Ethereum ecosystem is Mythril. It is a security analysis tool that uses concolic analysis, taint analysis, and a control flow checking to detect a variety of security vulnerabilities.

  2. Mythril is based on Python and you need a working installation of Python v3 with pip3 installed. Once you have those ready, run the following command to install Mythril:
pip3 install mythril
Concolic analysis is a hybrid code analysis technique that performs symbolic execution. It considers the program variables as symbolic variables along a concrete execution path. Symbolic execution is used in conjunction with new test cases to maximize code coverage. The main focus of this technique is to find bugs and vulnerabilities in a real-world scenario, rather than verifying code correctness.

Taint analysis checks for variables that can be modified by an external user interaction. This helps in understanding the information flow characteristics of a contract.
  1. You can also get it as a Docker image. Run the following command to pull it from docker Hub:
docker pull mythril/myth
  1. Once you have installed mythril, perform analysis on a file to get a report:
myth -x erc20.sol
  1. The Remix IDE (https://remix.ethereum.org/) also has inbuilt analysis capabilities to find common security flaws and best practices. To perform validation, go to the analysis tab and click Run. This will list all the issues in the given contract.

  1. Oyente (https://github.com/melonproject/oyente) is a Remix-based IDE that focuses more on security. It provides both a UI and a command-line option to analyze smart contracts.

  2. Generating a DOT graph can better help you visualize the contract. Solgraph is a tool that is built for this purpose. Install solgraph via npm using the following command. You need to have a working installation of Node.js for this:
npm install --save -g solgraph
  1. After installing solgraph, use the smart contract file as an input to generate a DOT graph. It will generate a visualization explaining the control flow of the contract:
solgraph contract.sol > contract.dot
  1. The community has also developed a lot of linting tools for solidity. Use any of the following tools to verify your code against best practices:
npm install -g solium
// OR
npm install -g solhint
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.147.77