https://github.com/zchn/ethereum-analyzer
An Ethereum contract analyzer.
https://github.com/zchn/ethereum-analyzer
Last synced: 4 months ago
JSON representation
An Ethereum contract analyzer.
- Host: GitHub
- URL: https://github.com/zchn/ethereum-analyzer
- Owner: zchn
- License: apache-2.0
- Created: 2017-04-16T21:17:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-22T02:15:30.000Z (over 1 year ago)
- Last Synced: 2025-12-07T23:56:03.168Z (6 months ago)
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/ethereum-analyzer
- Size: 1.92 MB
- Stars: 19
- Watchers: 2
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ethereum-analyzer [](https://hackage.haskell.org/package/ethereum-analyzer) [](https://travis-ci.org/zchn/ethereum-analyzer)
- [Usage](#usage)
- [Solidity Control Flow Graph (CFG) Generation](#solidity-control-flow-graph-cfg-generation)
- [Solidity Linter (WIP)](#solidity-linter-wip)
- [EVM CFG Generation](#evm-cfg-generation)
## Usage
### Solidity Control Flow Graph (CFG) Generation
```shell
stack build --profile &&\
solc --combined-json ast examples/etherscan.io/CryptoKittiesCore.sol |\
stack exec -- ea-analyze &&\
find work/ -name "*.dot" -exec dot -Tpng -O \{\} \;
```
generates CFGs like

whose original code looks like
```javascript
function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalCats = totalSupply();
uint256 resultIndex = 0;
uint256 catId;
for (catId = 1; catId <= totalCats; catId++) {
if (kittyIndexToOwner[catId] == _owner) {
result[resultIndex] = catId;
resultIndex++;
}
}
return result;
}
}
```
### Solidity Linter (WIP)
``` shell
stack build
solc --combined-json ast\
examples/analysis-benchmark/selfdestruct-over-suicide.sol |\
stack exec ea-analyze
```
### EVM CFG Generation
``` shell
stack build
cat examples/etherscan.io/CryptoKittiesSalesAuction.evm | stack exec -- ea-bytecode-vis --outDot=work/tmp.dot &&\
dot -Tpng work/tmp.dot -O
```
generates a pretty large CFG for the whole EVM bytecode sequence, part of which
looks like
