Cli tool to get smart contract code + ABI on EVM-based chains for ease of piping and viewing at terminal (e.g. with vim or others).
It supports BSC, Ethereum, and Polygon.
cargo install tracpls
Users are required to define environment variables of the following depending on API platforms which provide the service off-chain
TRACPLS_BSCSCAN_APIKEY
- API key from bscscan.comTRACPLS_ETHERSCAN_APIKEY
- API key from etherscan.ioTRACPLS_POLYGONSCAN_APIKEY
- API key from polygonscan.comAt runtime, the program will select the appropriate one which dictated by flag
--chain
(or -c
) then grab the API key then use it as such.
The following options are available
``` $ tracpls --help tracpls Wasin Thonkaew (wasin@wasin.io) cli tool to get smart contract code and its ABI for ease of viewing on terminal
USAGE: tracpls [OPTIONS] --address
--chainOPTIONS: -a, --address
Target contract address to get its smart contract code or ABI from --abi-only Get only contract ABI -c, --chainAlways use --chain (or -c) to specify chain type whose possible values are either
bsc
,ethereum
, orpolygon
.
bash
$ tracpls -a 0x0000000000000000000000000000000000001004 -c bsc | vim -c "set syntax=solidity" -
You might not need -c "set syntax=solidity"
if you already configured your
~/.vimrc
to support solidity syntax highlighting.
bash
$ tracpls -a 0x0000000000000000000000000000000000001004 --chain bsc --abi-only > abi.json
bash
$ tracpls -a 0x0000000000000000000000000000000000001004 --chain bsc --abi-only --no-abi-pretty-print > abi.json
bash
$ tracpls -a 0x1befe6f3f0e8edd2d4d15cae97baee01e51ea4a4 --chain bsc --out-dir /tmp/0x1bef
/tmp/0x1bef/contracts/LpMigration.sol
/tmp/0x1bef/@openzeppelin/contracts/access/Ownable.sol
/tmp/0x1bef/@openzeppelin/contracts/utils/Context.sol
/tmp/0x1bef/@openzeppelin/contracts/utils/math/SafeMath.sol
/tmp/0x1bef/@openzeppelin/contracts/security/ReentrancyGuard.sol
/tmp/0x1bef/@openzeppelin/contracts/token/ERC20/IERC20.sol
bash
$ tracpls -a 0x1befe6f3f0e8edd2d4d15cae97baee01e51ea4a4 --chain bsc --out-dir /tmp/0x1bef -s
Error message will always be outputted to stderr
. So normal correct and proper
output won't be interfere with the error message. But you are free to combine
them into one.
MIT, Wasin Thonkaew