{"id":22399909,"url":"https://github.com/laugharne/select0r","last_synced_at":"2025-08-10T00:07:44.421Z","repository":{"id":200104647,"uuid":"704432843","full_name":"Laugharne/select0r","owner":"Laugharne","description":"Selector value optimizer, find better EVM function name to optimize Gas cost.  Solidity functions can achieve higher efficiency when their function selector consists mainly of zeros.","archived":false,"fork":false,"pushed_at":"2025-07-25T08:34:36.000Z","size":77,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-25T14:14:58.311Z","etag":null,"topics":["abi","contracts","function-dispatcher","gas","keccak","keccak-256","keccak256","multi-threading","optimization","rust","rust-lang","smart-contracts","solidity","solidity-contracts","zeros"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Laugharne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-13T08:46:33.000Z","updated_at":"2025-07-25T08:34:40.000Z","dependencies_parsed_at":"2024-02-04T14:25:06.774Z","dependency_job_id":"52cad2b9-6a69-4b71-a62e-1f45f3f4ca16","html_url":"https://github.com/Laugharne/select0r","commit_stats":null,"previous_names":["laugharne/select0r"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Laugharne/select0r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laugharne%2Fselect0r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laugharne%2Fselect0r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laugharne%2Fselect0r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laugharne%2Fselect0r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Laugharne","download_url":"https://codeload.github.com/Laugharne/select0r/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Laugharne%2Fselect0r/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269655001,"owners_count":24454357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abi","contracts","function-dispatcher","gas","keccak","keccak-256","keccak256","multi-threading","optimization","rust","rust-lang","smart-contracts","solidity","solidity-contracts","zeros"],"created_at":"2024-12-05T08:10:29.385Z","updated_at":"2025-08-10T00:07:44.376Z","avatar_url":"https://github.com/Laugharne.png","language":"Rust","readme":"# Select0r\n\n\u003c!-- TOC --\u003e\n\n- [Select0r](#select0r)\n\t- [🔭 Overview](#-overview)\n\t- [📦 Install Rust](#-install-rust)\n\t- [🔧 Build](#-build)\n\t- [🚀 How to run](#-how-to-run)\n\t\t- [💻 Usage](#-usage)\n\t\t- [✏️ Parameters](#-parameters)\n\t\t- [👉 Examples](#-examples)\n\t- [📝 Results](#-results)\n\t- [🎉 Yad bonus !](#-yad-bonus-)\n\t\t- [📦 Installation](#-installation)\n\t\t- [💻 Script](#-script)\n\t- [TO DO](#to-do)\n\n\u003c!-- /TOC --\u003e\n\n\n## 🔭 Overview\n\nSolidity functions can achieve higher efficiency when their function selector consists mainly of zeros.\n\nThis tool helps you to generate a new selector for your Solidity contracts and save gas costs by using the smallest possible selector.\n\nFor instance :\n- `sendValue(uint256 amount)` is **invalid**.\n- `sendValue(uint256)` is the **correct** format.\n\nThe gas cost of a function name equals 4 times the number of zero bytes and 16 times the number of non-zero bytes. Therefore, the gas cost ranges from **28 gas** (*3 zeros and 1 non-zero*) in the best case to **64 gas** (*4 non-zero bytes*) in the worst case.\n\n1. It's important to note that an all-zero function selector won't compile because it conflicts with the fallback function. Consequently, `mint_22F5A30(uint256)` (**0a000000**) is more gas-efficient than `mint(uint256)` (**a0712d68**).\n\n2. Function selectors with **leading zeros** affect the operation of the function dispatcher and can be processed more quickly with less gas consumption.\n\nThis Rust program (**select0r**) is designed to find better names for an EVM (Ethereum Virtual Machine) function to optimize gas cost. It takes a function signature as input and performs calculations to find the best EVM function names in terms of gas cost.\n\nFor more informations about **gas optimisation** related to **function names**, go check **my article**, please follow and share it !\n\n**Links :**\n-  **[GitHub - Laugharne/Optimal_Function_Names](https://github.com/Laugharne/Optimal_Function_Names)**\n- **[Optimisation des EVM, avec les noms de fonctions | Medium]( https://medium.com/@franck.maussand/optimisation-sur-ethereum-faites-la-diff%C3%A9rence-avec-les-noms-de-fonctions-ba4692c9e39f)** 🇫🇷\n- **[Optimization on Ethereum: Make a Difference with Function Names](https://medium.com/coinsbench/optimization-on-ethereum-make-a-difference-with-function-names-9cc4a963424b)** 🇬🇧\n\n**Feel free to [contact me !](mailto:franck@maussand.net)**\n\n----\n\n## 📦 Install Rust\n\n[https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install)\n\n\n## 🔧 Build\n\nBuild artifacts in release mode, with optimizations.\n\n`cargo build --release`\n\n\n----\n\n## 🚀 How to run\n\nGo into `release` sub-directory as working directory and launch `select0r`.\n\n\n### 💻 Usage\n\n`select0r s \u003cfunction_signature string\u003e z \u003cnumber_of_zeros\u003e r \u003cmax_results\u003e l \u003cleading_zero boolean\u003e t \u003cnbr_threads\u003e o \u003cformat_ouput\u003e`\n\n\n### ✏️ Parameters\n\n| Parameters | Parameter names      | Data types | Examples      | Domains              | Default       | Descriptions              |\n| ---------- | -------------------- | ---------- | ------------- | -------------------- | ------------- | ------------------------- |\n| **`s`**    | `function_signature` | string     | mint(address) | *(1)*                | **Mandatory** | Function signature *(1)*  |\n| **`z`**    | `number_of_zeros`    | numeric    | 2             | [1..3]               | **2**         | Minimal # of zero *(2)*   |\n| **`r`**    | `max_results`        | numeric    | 5             | [2..10]              | **4**         | # of needed result *(2)*  |\n| **`l`**    | `leading_zero`       | boolean    | true          | true/false           | **false**     | *(3)*                     |\n| **`t`**    | `nbr_threads`        | numeric    | 4             | [2..#cpu]            | **2**         | # of threads to use (*4*) |\n| **`o`**    | `format_ouput`       | string     | xml           | tsv/csv/json/xml/ron | **tsv**       | File format output *(5)*  |\n\n- *(1) : no spaces, no parameter names, just a [valid solidity signature](https://docs.soliditylang.org/en/develop/abi-spec.html#function-selector)*\n- *(2) : higher it is, longer it is*\n- *(3) : search for leading zeros in priority, slower if true*\n- *(4) : hardware limitation (#CPU)*\n- *(5) : File formats*\n  - **tsv** *= [Tab Separated Value](https://en.wikipedia.org/wiki/Tab-separated_values)*\n  - **csv** *= [Comma Separated Value](https://en.wikipedia.org/wiki/Comma-separated_values)*\n  - **json** *= [JavaScript Object Notation](https://www.json.org/json-en.html)*\n  - **xml** *= [Extensible Markup Language](https://en.wikipedia.org/wiki/XML)*\n  - **ron** *= [Rusty Object Notation](https://github.com/ron-rs/ron)*\n\n\n### 👉 Examples\n\n```bash\nselect0r s \"functionName(uint256)\"  z 2  r 5  l true  t 2  o tsv\n```\n\n```bash\nselect0r s \"functionName2(uint)\"  z 2  r 7  l false  t 2  o json\n```\n\n```bash\nselect0r s \"deposit(uint)\"  z 2  r 7  l false  t 2  o xml\n```\n\n\n----\n\n## 📝 Results\n\nGet results for `execute()` signature looking for `2` lead zeros minimum, using `15` threads, stop after`8` results and put it as an `XML` file.\n\n```bash\nselect0r s \"execute()\"  z 2  l true  t 15  r 8  o xml\n```\nAn ouput file appears with the initial signature and some parameters in its name.\n\n**File :** `select0r-execute()--zero=2-max=8-lead=true-cpu=15.XML`\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cselect0r\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e61461954\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e0\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e0\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e1b9b0000\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e2\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e0\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_1qn()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e00af0043\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e2\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e1\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_5Hw()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e00940050\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e2\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e1\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_6Ii()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e0000eb63\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e2\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e2\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_mAX()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e0000cf6d\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e2\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e2\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_G5J()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e00000622\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e2\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e2\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_06SF()\u003c/signature\u003e\n    \u003c/result\u003e\n    \u003cresult\u003e\n        \u003cselector\u003e000000ae\u003c/selector\u003e\n        \u003cnbr_of_zero\u003e3\u003c/nbr_of_zero\u003e\n        \u003cleading_zero\u003e3\u003c/leading_zero\u003e\n        \u003csignature\u003eexecute_6d4S()\u003c/signature\u003e\n    \u003c/result\u003e\n\u003c/select0r\u003e\n```\n\n\n\n--------\n\n\n## 🎉 Yad bonus !\n\n**Yad** (« [Yet Another Dialog](https://doc.ubuntu-fr.org/yad_yet_another_dialog) ») is a tool to create graphic dialog boxes with shell scripts.\n\n![](assets/yad_select0r.png)\n\nResources : [YAD Guide](https://yad-guide.ingk.se/)\n\n\n### 📦 Installation\n\n```bash\nsudo apt install yad\n```\n\n\n### 💻 Script\n\nThere is the code to provide graphical interface to **select0r** tool.\n\nJust set path to select0r binary executable and wrap it into a shell script or a bash function.\n\n```bash\nselect0r=$(yad \\\n--title='Select0r' \\\n--form --width 400 --height 300 \\\n--field=\"\u003cb\u003eFind better function name to optimize gas cost.\u003c/b\u003e\":LBL '' \\\n--field=\"\":LBL '' \\\n--field=\"Signature\" 'mint(address)' \\\n--field=\"Nbr of Results\":CB '1\\!2\\!3\\!^4\\!5\\!6\\!7\\!8\\!9\\!10\\!11\\!12' \\\n--field=\"Nbr of zero\":CB '1\\!^2\\!3' \\\n--field=\"Nbr of Threads\":CB '1\\!^2\\!3\\!4\\!5\\!6\\!7\\!8\\!9\\!10\\!11\\!12\\!13\\!14\\!15\\!16' \\\n--field=\"Ouput\":CB '^TSV\\!CSV\\!JSON\\!XML' \\\n--field=\"Leading 0\":CHK 'FALSE' \\\n)\nsignature=$(echo \"$select0r\" | awk 'BEGIN {FS=\"|\" } { print $3 }')\nnn_result=$(echo \"$select0r\" | awk 'BEGIN {FS=\"|\" } { print $4 }')\nnn_zero=$(echo \"$select0r\" | awk 'BEGIN {FS=\"|\" } { print $5 }')\nnn_threads=$(echo \"$select0r\" | awk 'BEGIN {FS=\"|\" } { print $6 }')\noutput=$(echo \"$select0r\" | awk 'BEGIN {FS=\"|\" } { print $7 }')\ndecrease=$(echo \"$select0r\" | awk 'BEGIN {FS=\"|\" } { print $8 }')\npath_to_select0r/select0r  s $signature  z $nn_zero  l $decrease  t $nn_threads  r $nn_result  o $output\n```\n\n## TO DO\n\n- Add : Rows of String Values (RSV) format ouput [GitHub - Stenway/RSV-Specification: Rows of String Values (RSV Data Format) Specification - A Binary Alternative to CSV](https://github.com/Stenway/RSV-Specification)\n- Add : Simple Markup Language (SML) format output [SML - The Simple Markup Language](https://www.simpleml.com/)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaugharne%2Fselect0r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaugharne%2Fselect0r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaugharne%2Fselect0r/lists"}