Code Monkey home page Code Monkey logo

solidity-cfg-builder's Introduction

solidity-cfg-builder

A control-flow graph builder for Solidity smart contracts.

Overview

This package generates a control-flow graph from Solidity contracts. Control-flow graphs are helpful as a graphic representation of the semantics of programs, and are the basis of many static analysis approaches to optimizing and verifying programs. This package is the basis of a static analysis approach I am currently developing.

solidity-cfg-builder is developed in Haskell, utilising a Solidity syntax parser used in the runtime verification tool for Solidity contractLarva. The version of the parser used in the project is packaged in the project.

This tool given Solidity code generates a control-flow graph in DOT notation, which can be visualised using GraphViz.

Building the tool

Requirements: cabal v2.4.* (e.g. install the full Haskell Platform)

Compilation: Follow the instructions here

Tool usage:

For correct results always make sure that the Solidity code compiles with a Solidity compiler.

To use the tool pass the location of a solidity file and the preferred location of the output to the executable, e.g. execute:

"./solidity-cfg-builder" <solidity-code.sol> <cfg.gv>

License

This project is licensed under the terms of the Apache 2.0 license.

TODO (See Issues for an up-to-date list)

  1. Handle function modifiers
  2. Allow option to flatten CFGs with function calls (consider also contract inheritance)
  3. Handle block of statements at end of function definition
  4. Event triggering is being parsed as a function call. Post-process to show triggerring of event explicitly.

FAQ and Common Problems

When compiling the code I get the error: Could not find module ‘Text.Parsec’.

Make sure you have installed parsec. Also, see this stackoverflow thread (https://stackoverflow.com/questions/9058914/cant-find-parsec-modules-in-ghci)

cabal install parsec

solidity-cfg-builder's People

Contributors

shaunazzopardi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.