Last active
June 16, 2021 16:49
-
-
Save computerphysicslab/4f1c7d4f1695e3d802516152681025b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get all events from contracts: | |
find . -type f -name '*.sol' ! -path '*node_modules/*' -print0 | xargs -0 sed -z "s/\/\/[^\n]*\n//g" | awk '/event/,/;/' | sed "s/[[:space:]]+event/event/" | sed -z "s/\n[\t ]*//g" | sed -z "s/;/;\n/g" | egrep "^event " | |
Get all event selectors from contracts: | |
find . -type f -name '*.sol' ! -path '*node_modules/*' -print0 | xargs -0 sed -z "s/\/\/[^\n]*\n//g" | awk '/event/,/;/' | sed "s/[[:space:]]+event/event/" | sed -z "s/\n[\t ]*//g" | sed -z "s/;/;\n/g" | egrep "^event " | sed "s/ indexed / /g" | sed -E "s/(address|u*int[0-9]+|bytes[0-9]*|bool|string)(\[\])* [^,\)]+/\1/g" | sed "s/event //" | sed -r "s/\s+//g" | |
NodeJS Script to compute topic hash: | |
const keccak256 = require('keccak256') | |
console.log("0x" + keccak256('Transfer(address,address,uint256)').toString('hex')) | |
... | |
Extracting all function complete declarations: | |
find . -type f -name '*.sol' ! -path '*node_modules/*' -print0 | xargs -0 sed -z "s/\/\/[^\n]*\n//g" | awk '/function/,/{/' | awk '/function/,/;/' | sed "s/[[:space:]]+function/function/" | sed -z "s/\n[\t ]*//g" | sed -z "s/{/\n/g" | sed -z "s/;/\n/g" | egrep --text "^function " | |
Extracting all function names and corresponding contracts: | |
egrep -rInH --include "*.sol" --exclude-dir=node_modules "^\W*function " | sed -r "s/(sol:[0-9]+):.*function /\1\t/g" | sed -r "s/\(+.*$//g" | |
Extracting all function signatures: | |
find . -type f -name '*.sol' ! -path '*node_modules/*' -print0 | xargs -0 sed -z "s/\/\/[^\n]*\n//g" | awk '/function/,/{/' | awk '/function/,/;/' | sed "s/[[:space:]]+function/function/" | sed -z "s/\n[\t ]*//g" | sed -z "s/{/\n/g" | sed -z "s/;/\n/g" | egrep --text "^function " | egrep --text " (public|external) " | sed -E "s/(address|u*int[0-9]+|bytes[0-9]*|bool|string)(\[[0-9]*\])* [^,\)]+/\1/g" | sed "s/function //" | sed -r "s/ (public|external).*$//" | sed -r "s/\s+//g" | |
-- | |
https://www.4byte.directory/ | |
There are 175,357 signatures in the database |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment