1 unstable release

0.1.0 Jan 3, 2023

#6 in #solidity-smart

21 downloads per month

MIT/Apache

365KB
448 lines

Selectoor

Selectoor is a CLI tool that generates optimal function names so that the solidity function selector has a good number of zero bytes. This helps reduce the gas cost of calling the function due to cheaper zero byte calldata.

selectoor

Installation

To install this tool, first clone the repository.

git clone git@github.com:AdithyaNarayan/selectoor.git

Install the tool globally using cargo.

cargo install --path selectoor

Usage

After installation, the binary will be available as selectoor.

Pull up the help screen with --help

selectoor --help
selectoor generate --help

Currently, the tool supports providing human-readable abi or function signature using the -s flag and the generated ABI JSON artifact using the -a flag.

selectoor generate -s "transfer(address _to, uint256 _amount)"

The CLI will automatically strip the variable names and generate a list of function signatures with optimal selectors.

The CLI does this by generating prefixes of fixed length to the function name, so as to not compromise on readability while maintaining low gas cost. Example: transfer(address,uint256) -> transfer_XXXX(address,uint256)

Features

  • Generate signature with suffixes
  • Parse human-readable signatures
  • Read abi file and generate optimal signatures for all the external functions
  • Stop searching when the first matching signature is found
  • selectoor fmt that modifies all *.sol files and replaces the function singatures

Please feel free to raise a pull request or issues for more features.

Dependencies

~22–38MB
~613K SLoC