{"id":18626971,"url":"https://github.com/tracyspacy/stringsforenumlib","last_synced_at":"2025-11-04T01:30:28.070Z","repository":{"id":193926601,"uuid":"689737909","full_name":"tracyspacy/StringsForEnumLib","owner":"tracyspacy","description":"A Solidity library for returning string values for enum elements.","archived":false,"fork":false,"pushed_at":"2023-09-11T17:53:05.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T06:25:55.277Z","etag":null,"topics":["enum","library","soldiity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tracyspacy.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-09-10T18:43:49.000Z","updated_at":"2023-09-10T19:37:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"1faa2fff-9d85-495e-a3ac-b5d3f2787a2c","html_url":"https://github.com/tracyspacy/StringsForEnumLib","commit_stats":null,"previous_names":["tracyspacy/stringsforenumlib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tracyspacy%2FStringsForEnumLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tracyspacy%2FStringsForEnumLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tracyspacy%2FStringsForEnumLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tracyspacy%2FStringsForEnumLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tracyspacy","download_url":"https://codeload.github.com/tracyspacy/StringsForEnumLib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239425309,"owners_count":19636346,"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","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":["enum","library","soldiity"],"created_at":"2024-11-07T04:39:41.091Z","updated_at":"2025-11-04T01:30:28.009Z","avatar_url":"https://github.com/tracyspacy.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solidity StringsForEnum Library\n\n\n## Overview\nMy motivation was to create a library that while works with / modifies contract storage, is still simple to interact with (as simple as a.toString(), without complex parameters).  \n\nStringsForEnum is a Solidity library example that provides a solution to a limitation in Solidity's native support for enumerated types (enums). By default, Solidity does not support string values for enums. This library overcomes this limitation, making it easier for developers to work with enums by allowing them to get string values for enum elements.\n\n\n\n## Functions\n- **isValidEnumValue(uint8 value)**: Verifies if an enum value is valid, i.e., its string equivalent is not empty.\n- **toString(uint8 value)**: Transforms an enum value (uint8) to its corresponding string equivalent. Throws a `NotValidEnumValue` error if the enum value is not valid.\n- **toIntWithString(uint8 value)**: Returns an enum value along with its string equivalent. Throws a `NotValidEnumValue` error if the enum value is not valid.\n\n\n## Usage Example\n\n```\nenum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }\nActionChoices choice;\n\n// Returns uint as default\n// GoLeft     - 0\n// GoRight    - 1\n// GoStraight - 2\n// SitStill   - 3\n\nfunction get() public view returns (ActionChoices) {\n        return choice;\n    }\n// returns 0\n\nusing StringsForEnum for uint8;\n...\nfunction getChoiceStr() public view returns (string memory){\n        return uint8(choice).toString();\n    }\n// returns specified String Value for ex. \"GoLeft\"\n```\n\n* string values have to specified in advance, see [example contract](https://github.com/tracyspacy/StringsForEnumLib/blob/main/contracts/testEnumContract.sol)\n    \n\n## Usage\n\nTo leverage this library, import it in your Solidity contract and utilize its functions as per your requirements.\nPlease do your own comprehensive analysis and tests before using it!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftracyspacy%2Fstringsforenumlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftracyspacy%2Fstringsforenumlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftracyspacy%2Fstringsforenumlib/lists"}