Giter VIP home page Giter VIP logo

solidity-flattener's Introduction

Solidity Flattener

A BlockCAT Technologies contribution - https://blockcat.io

Are you tired of having to manually combine all of your files when verifying your contract source on Etherscan? This script automatically traverses the dependency graph and outputs all of your imports in the correct order, ready to be pasted into the contract verifier.

This is also useful for quickly throwing your source into Remix without having to fumble with local filesystem connections.

NOTE: This script does not work with imports that are aliased (i.e. import './A.sol' as B; ).

Requirements

  • Python 3.5+, pip
  • solc, the Solidity compiler
    • Note: The NPM version of the compiler does not expose enough functionality to satisfy the requirements of this tool.

Installation

pip install solidity-flattener

Usage

usage: solidity_flattener [-h] [--output FILENAME] [--solc-paths SOLC_PATHS]
                          target_solidity_file

Flattens a target Solidity source file by resolving all of its imports and
dependencies. NOTE: This does not work with imports that are aliased (i.e.
import './A.sol' as B; )

positional arguments:
  target_solidity_file  Specifies the target Solidity source file to flatten.

optional arguments:
  -h, --help            show this help message and exit
  --output FILENAME     Specifies the output destination filename. Outputs to
                        stdout by default.
  --solc-paths SOLC_PATHS
                        Specifies the path replacements to pass onto solidity.
                        Can be specified multiple times. See solc --help for
                        more information.
  --solc-allow-paths SOLC_ALLOW_PATHS
                        Specifies allowed paths for solidity imports. See solc
                        --help for more information.

Examples

To flatten a Solidity file:

solidity_flattener StandardToken.sol

To output to a file instead of standard out:

solidity_flattener --output StandardTokenFlattened.sol StandardToken.sol

To provide import path redirections:

solidity_flattener --solc-paths="my_solidity_path=my_actual_path" StandardToken.sol

Contributions

Pull requests are welcome, or feel free to open an issue to discuss.

solidity-flattener's People

Contributors

stickerpants avatar

Watchers

 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.