selectoor

Crates.ioselectoor
lib.rsselectoor
version0.1.0
sourcesrc
created_at2023-01-03 05:14:02.496029
updated_at2023-01-03 05:14:02.496029
descriptionAn easy-to-use CLI tool to generate optimal function selectors for Solidity smart contracts
homepage
repositoryhttps://github.com/adithyanarayan/selectoor
max_upload_size
id749917
size436,646
Adithya Narayan (AdithyaNarayan)

documentation

README

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.

Commit count: 3

cargo fmt