Crystal-Clear CLI: Smart Contract Supply Chain 🔗
Analyze and visualize Ethereum smart contract dependencies with ease. SCSC helps you understand contract interactions by generating detailed call graphs from on-chain data.
✨ Features
- 📊 Generate comprehensive call graphs from smart contract interactions
- 🔍 Analyze contract dependencies across specified block ranges
- 📈 Export visualizations in DOT format for further analysis
- ⚙️ Flexible configuration options for node connections and logging
🚀 Quick Start
Prerequisites
- Python 3.12 or higher
- Access to an Archive Ethereum node (local or remote)
- Allium API access: optional, used to enrich addresses with labels
- Etherscan API access: required for retrieving verified smart contract source code
- Poetry
Installation
# Clone the repository
git clone https://github.com/mab-xyz/crystal-clear.git
cd crystal-clear/webapp/backend/crystal-clear
# Install with Poetry
poetry install
# Activate the environment
poetry shell
💻 Usage
Crystal-Clear CLI provides two main commands:
1. Analyze Dependencies Command
Dependency Graph
# note the RPC node must have method trace_filter
crystal-clear dependency --node-url <node_url> \
--address <contract_address> \
--from-block <block> \
--to-block <block> \
[options]
# this exports the smart contract dependency graph
crystal-clear dependency --node-url <node_url>
--address 0xE592427A0AEce92De3Edee1F18E0157C05861564 \
--from-block 0x14c3b86 \
--to-block 0x14c3b90 \
--export-dot graph.dot
Risk analysis per contract (computes the risk factors, incl. proxy and permission risks)
You can select the scope of the analysis:
single– assesses the risk of the specified contract only.supply-chain– assesses the risk of the contract and all dependent contracts in its supply chain.
crystal-clear risk --etherscan-api-key <etherscan_api> \
--node-url <node_url> \
--scope [single|supply-chain]
--address <contract_address> \
[options]
crystal-clear risk
--address 0xE592427A0AEce92De3Edee1F18E0157C05861564 \
--scope single
--export-json analysis.json
Key Parameters
| Parameter | Description | Example |
|---|---|---|
--node-url |
Ethereum node URL | http://localhost:8545 |
--allium-api-key |
Allium API Key | `` |
--etherscan-api-key |
Etherscan API Key | `` |
--address |
Contract address to analyze | 0xE592427A0AEce92De3Edee1F18E0157C05861564 |
--from-block |
Starting block number (hex/decimal) | 0x14c3b86 or 21665670 |
--to-block |
Ending block number (hex/decimal) | 0x14c3b90 or 21665680 |
--log-level |
Logging verbosity (analyze only) | ERROR, INFO, DEBUG |
--export-dot |
Output file for DOT graph (analyze only) | output.dot |
--export-json |
Output file for JSON (analyze only) | output.json |
🛠️ Development
We use modern Python tools to maintain high code quality:
- Black: Code formatting
- Ruff: Fast Python linting
- pre-commit: Git hooks
Set up the development environment:
# Install development dependencies
poetry install --with dev
# Set up pre-commit hooks
pre-commit install
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Metadata
Release files for mab-crystal-clear 1.0.45
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mab_crystal_clear-1.0.45.tar.gz | 41.8 kB | Without provenance | Details for mab_crystal_clear-1.0.45.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mab_crystal_clear-1.0.45-py3-none-any.whl | Python 3 | none | any | Details for mab_crystal_clear-1.0.45-py3-none-any.whl |
Total release size: 92.0 kB
Release files / mab_crystal_clear-1.0.45.tar.gz
| Download URL | mab_crystal_clear-1.0.45.tar.gz |
|---|---|
| Size | 41.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c50b078ca6755bfe3216f905482fb4f026f9907c0f1a0d6943ed5b282bcc0db
|
|
BLAKE2b-256 checksum How to use checksums |
1ecc2a49cadeb4a07ee99a5cd822f5d8ca1af3e96c2aaf7611f82cb4f7e99808
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.16 Linux/7.0.0-1019-azure
|
Release files / mab_crystal_clear-1.0.45-py3-none-any.whl
| Download URL | mab_crystal_clear-1.0.45-py3-none-any.whl |
|---|---|
| Size | 50.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5af44ecab9490ffe36299aa457751fa2de8bd429c282f91441292eac34d57413
|
|
BLAKE2b-256 checksum How to use checksums |
62ebea80a60c830f4b1f054f913ec808bf96ebbd7cf574fc33e46e31542c86eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.12.16 Linux/7.0.0-1019-azure
|
Security for mab-crystal-clear 1.0.45
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.