Skip to main content

Solidity Flatliner

Unfolds all local imports in a solidity file to generate a flat solidity file.

Introduction

Manually combining all imports in a solidity file when verifying your contract source on Etherscan is time-consuming and cumbersome. This tool automatically traverses the dependency graph of imports and combines them in the correct order, which is ready to be pasted into the contract verifier.

NOTE: This tool won't work with imports that are aliased (i.e. import "./foo.sol" as bar; )

Features

  • support external library folder destination
  • support output folder name
  • auto remove redundant license place and solidity version code
  • auto remove redundant contract / interface / abstract contract / library
  • added support safety line

Installation

There are no requirements for this tool.

pip3 install solflatliner

or if you want to get the upgrade

sudo pip3 install solflatliner --upgrade

Create bin file for easy execution

#!/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
# -*- coding: utf-8 -*-
import re
import sys
from solflatliner.cmd import cli
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

Usage

usage: solflatliner [-h] [-o *.sol] *.sol *.*.*

Unfolds all local imports in a solidity file to generate a flat solidity file.
Put the output file into out/ folders.

positional arguments:
  *.sol                 Target filename with imports
  *.*.*                 Solidity compiler version e.g. 0.4.24

optional arguments:
  -h, --help            Show this help message and exit
  -o *.sol, --output *.sol
                        Output filename (default: flat.sol)
  -f, --ofolder         The output folder (default: verify)
  -lib, --library       Selection of library folder from the execution path. (default: lib)
  -l, --license         The license identifier from https://spdx.org/licenses/ (default: AGPL-3.0)

Example

solu contract-with-imports.sol 0.4.24

It will output flat.sol (default output filename) with solidity version 0.4.24 in verify/ folder.

solflatliner contract-with-imports.sol 0.4.20 --output contract-flat.sol

It will output contract-flat.sol with solidity version 0.4.20 in verify/ folder.

License

MIT License (2022), Jun-You Liu, Heskemo

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solflatliner-1.0.118.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solflatliner-1.0.118-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file solflatliner-1.0.118.tar.gz.

File metadata

  • Download URL: solflatliner-1.0.118.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for solflatliner-1.0.118.tar.gz
Algorithm Hash digest
SHA256 0fbfd2170a13a1a7ec65a2cfd4f94fe974f7e364053308dc73e32973e44e4fa2
MD5 07b543c0344330c69d7e90904ebd0e63
BLAKE2b-256 cb1a5e421d007b0f55f77fc7b60f8b1e337c9f9f046fb9bb3590629bf86cd2f2

See more details on using hashes here.

File details

Details for the file solflatliner-1.0.118-py3-none-any.whl.

File metadata

  • Download URL: solflatliner-1.0.118-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for solflatliner-1.0.118-py3-none-any.whl
Algorithm Hash digest
SHA256 dd9d3673b89f2c73ce9521752f49eac41b3de64e4dd047c8d8e6f3ad2b305b87
MD5 53f47b37b9b708b95102bc9e5034867b
BLAKE2b-256 4d549715b297848417aeabda348a891a9cda3fc551d1401cb3e5c805ddbaeb5b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.118 This release

2 files

1.0.117

2 files

1.0.116

2 files

1.0.115

2 files

1.0.114

2 files

1.0.113

2 files

1.0.110

2 files

1.0.109

2 files

1.0.108

2 files

1.0.107

2 files

1.0.106

2 files

1.0.105

2 files

1.0.104

2 files

1.0.103

2 files

1.0.102

2 files

1.0.101

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page