Skip to content

unpackdev/unpack

Repository files navigation

Tests Status Build Status Security Status Coverage Status Go Report Card License PkgGoDev Discord

{Un}Pack - Solidity (Ethereum) Smart Contract Analysis Toolchain

!!!DOCUMENTATION AND TOOL ITSELF IS UNDER DEVELOPMENT!!!

Overview

{Un}Pack is a robust modular toolchain designed for Solidity smart contract analysis across all EVM-compatible networks.

{Un}Pack toolchain, via JSON-RPC, is enabling users to decode transactions, logs, decompile opcodes, discover used standards and many more features listed here. Additionally, it offers the ability to search for specific functions and events by their signatures, providing a comprehensive toolkit for in-depth contract analysis and auditing. This enhanced search capability makes it easier for developers to quickly locate and analyze specific smart contracts components.

To manage the storage of large datasets without using Git LFS, we have opted to utilize Cloudflare R2. This object storage solution offers zero egress fees and is a cost-effective alternative to Amazon S3. As a result, the entire dataset is seamlessly integrated with this repository, eliminating the need for you to recreate the datasets independently.

Long story short, clone repo, configure only necessary settings, download, decompress and import datasets, start docker containers and enjoy playing with JSON-RPC services!

Features

  • Modular design: Easily extend {Un}pack with additional services, configuration or states. See examples module.
  • Easy dataset management: Import or export whole dataset with ease. More information can be found here.
  • Cloudflare R2 datasets: 7-zip datasets will be hosted on Cloudflare as it's much cheaper than S3 and there are no egress traffic charges!
  • Efficient Contract Downloading: Streamlined process for downloading Ethereum smart contracts.
  • Download Resumption: Capability to pause and resume downloads, ensuring progress isn't lost.
  • Local Storage Management: Stores contracts in Clickhouse and disk for quick access and efficient retrieval.
  • Source Code Access: Provides easy access to the source code of verified contracts on Etherscan, Bscscan, Sourcify.dev and internal Solgo.
  • JSON-RPC and GraphQL Support: For easier access to the data, including documentation and postman collection!
  • Advanced Decoding Tools: Utilize JSON-RPC to decode transactions, logs, decompile opcodes, and attempt ABI recreation of any deployed Ethereum smart contract.
  • Signature Search: Enables the searching of functions and events based on their signatures, enhancing the ability to analyze specific contract aspects efficiently.

This project is inspired from Smart Contract Sanctuary. For now, it will be focused only on mainnet contracts. Ethereum is the first one, Arbitrum, Binance Smart Chain and Polygon will be added later including others.

IMPORTANT

  • IN EARLY DEVELOPMENT: Unpacking works (95% of the time), however, compression and decompression including JSON-RPC and GraphQL are still not even close to be completed.
  • Otterscan JSON-RPC api is recommended. We use Erigon.
  • For dataset compression we use 7-Zip compression.
  • If you do not have an Erigon node, you will need to have Etherscan, Bscscan and/or BitQuery account to get contract creation information.
  • Due to licensing issues, we are not going to provide information that strictly breaks licenses. Instead, we are going to provide you the tools to extract information yourself if you have access to the 3rd party sources, utilising their respective API keys.

Datasets

We offer access to a collection of complete datasets, invaluable for researchers, developers, and analysts who require extensive real-world data for their projects. Below is a detailed guide to our available datasets, which include extensive records suitable for in-depth analysis in various fields.

These datasets are stored on R2, ensuring reliable and speedy access via direct download links.

Read more about how to export, import, compress, decompress, upload and download datasets here.

Blockchain datasets

Dataset Location Compressed Size Decompressed Size
Ethereum Contracts http://r2.unpack.dev/datasets/ethereum.7z 526.99 MB 17 GB
----- --- ---- ----
Total 526.99 MB 17 GB

Last Revision Date: 2024-04-23 09:45 CEST

Database datasets

Dataset Location Compressed Size Decompressed Size
Contracts http://r2.unpack.dev/datasets/contracts.clickhouse.7z 200.26 MB 4.71 GB
Metadata http://r2.unpack.dev/datasets/metadata.clickhouse.7z 11.67 MB 300 MB
Tokens http://r2.unpack.dev/datasets/tokens.clickhouse.7z 3.4 MB 10 MB
AST http://r2.unpack.dev/datasets/ast.clickhouse.7z 3.16 MB 10 MB
CFG http://r2.unpack.dev/datasets/cfg.clickhouse.7z 5.34 MB 50 MB
Constructors http://r2.unpack.dev/datasets/constructors.clickhouse.7z 54.52 MB 1.39 GB
Standards http://r2.unpack.dev/datasets/standards.clickhouse.7z 11.44 MB 1.42 GB
Variables http://r2.unpack.dev/datasets/variables.clickhouse.7z 97.73 MB 1.51 GB
Functions http://r2.unpack.dev/datasets/functions.clickhouse.7z 2.39 GB 40.98 GB
Events http://r2.unpack.dev/datasets/events.clickhouse.7z 80.57 MB 2.06 GB
----- --- ---- ----
Total 2.60 GB 53.54 GB

Last Revision Date: 2024-05-07 09:45 CEST

Documentation (WIP)

Documentation is currently being developed.

Begin your journey at the Welcome. For installation instructions, please consult the Installation guide.

Notes

  • For the best performance, it is recommended to run this project on NVMe storage. This is because the database is very large and requires fast read and write to the storage to perform well.

This project is not a new blockchain, due to it, key-value storage is not needed. Even more, it's a problem.

Database Statistics

Bellow is a database overview table, explaining the size of Clickhouse database as of last database push. This data is only informational and is here to give you a big picture, not the most accurate database size (as it changes from second to second).

Dataset Statistics

Table Records Uncompressed Size (MB) Compressed Size (MB)
Contracts Count 156,167 4,822.965 1,421.472
Metadata Count 129,910 29.296 18.049
AST Count 83,806 8.398 4.622
CFG Count 83,785 50.592 14.445
Standards Count 288,060 1,458.937 46.317
Tokens Count 77,883 9.325 4.532
Constructors Count 75,016 1,424.148 228.542
Variables Count 1,370,393 1,534.598 302.752
Functions Count 5,377,136 41,957.086 8,106.253
Events Count 505,876 2,112.991 256.472
Total Database Size (MB) -------- 53,408.336 10,403.458

Extending Inspector (Modules)

Please navigate to the Module to see how you can extend inspector with custom options, commands and services!

Demo and Examples

To be defined here. Will be a link with graphql playground, limited to 1req/s including examples in its own directory of how to consume this service. Additional note is that demo will go down and up as I work on it, served from my own datacenter. I am not promising any availability.

Please check out Examples directory for more information about how to use service.

Postman Collection (WIP)

For easy access, here is a publicly shared postman collection. Please note that it's still in early stages, WIP.

Run In Postman

LICENSE

I am offering this code, not related to contracts at no cost, under the MIT license. For more details about this license, please refer to the LICENSE file included in this repository.

Please note: The contracts themselves are subject to their respective licenses. These licenses can be found within the source code of each individual contract. It is imperative that you review and adhere to these licenses when using the contracts.

Message to Etherscan

I extend my sincere gratitude to the Etherscan team for your invaluable contributions. After reviewing your licensing terms, I believe that my use of your services aligns with these terms. However, should there be any concerns or issues regarding my usage, I welcome your feedback and guidance. Please feel free to contact me at info(at)unpack.dev.