| Crates.io | traverse-graph |
| lib.rs | traverse-graph |
| version | 0.1.3 |
| created_at | 2025-09-19 03:09:57.141145+00 |
| updated_at | 2025-09-21 17:30:47.316114+00 |
| description | Call graph analysis and visualization for Solidity smart contracts |
| homepage | https://github.com/calltrace/traverse |
| repository | https://github.com/calltrace/traverse |
| max_upload_size | |
| id | 1845720 |
| size | 800,229 |
Call graph analysis and visualization for Solidity smart contracts.
This crate provides comprehensive call graph generation and analysis capabilities for Solidity contracts. It identifies function relationships, external calls, and control flow patterns to help developers understand complex contract interactions.
use traverse_graph::{CallGraphBuilder, OutputFormat};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut builder = CallGraphBuilder::new();
// Add Solidity files
builder.add_file("contracts/Token.sol")?;
builder.add_file("contracts/Exchange.sol")?;
// Build the call graph
let graph = builder.build()?;
// Export to different formats
graph.to_dot("output/call_graph.dot")?;
graph.to_mermaid("output/call_graph.mmd")?;
Ok(())
}
This crate powers the sol2cg command-line tool:
# Generate a call graph from Solidity files
sol2cg contracts/*.sol -o call_graph.dot
# Convert to PNG using Graphviz
dot -Tpng call_graph.dot -o call_graph.png
digraph CallGraph {
"Token::transfer" -> "Token::_transfer";
"Token::_transfer" -> "Token::balanceOf";
}
graph TD
Token.transfer --> Token._transfer
Token._transfer --> Token.balanceOf
This crate is part of the Traverse suite of tools for Solidity code analysis, visualization, and test generation.
MIT OR Apache-2.0