{"id":34073410,"url":"https://github.com/playmint/cairo-type-hints","last_synced_at":"2026-03-12T19:14:27.538Z","repository":{"id":57680310,"uuid":"493203363","full_name":"playmint/cairo-type-hints","owner":"playmint","description":"Python module to generate type hints from Cairo","archived":false,"fork":false,"pushed_at":"2022-05-23T15:28:37.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-04T09:53:33.893Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/playmint.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}},"created_at":"2022-05-17T10:31:24.000Z","updated_at":"2022-05-18T11:37:13.000Z","dependencies_parsed_at":"2022-09-01T14:41:46.875Z","dependency_job_id":null,"html_url":"https://github.com/playmint/cairo-type-hints","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/playmint/cairo-type-hints","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playmint%2Fcairo-type-hints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playmint%2Fcairo-type-hints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playmint%2Fcairo-type-hints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playmint%2Fcairo-type-hints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playmint","download_url":"https://codeload.github.com/playmint/cairo-type-hints/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playmint%2Fcairo-type-hints/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30439658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T14:34:45.044Z","status":"ssl_error","status_checked_at":"2026-03-12T14:09:33.793Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-12-14T08:52:46.936Z","updated_at":"2026-03-12T19:14:27.514Z","avatar_url":"https://github.com/playmint.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cairo type hints\nAdd type hints to your Cairo-lang files and feed the generated json files to Stark-Dot-Net code generators.\n\n## Install\n```bash\npip install cairo-type-hints\n```\n\n## Example usage:\n```bash\npython compile-cairo-type-hints \\\n    -i ./src/my-awesome-contract.cairo \\\n    -o ./artifacts/hints/test-hints.json\n```\n\n## Adding hints to structs\nA type hint is a comment with a colon, a space and then a type. Valid types are `int`, `string`, and `address`. For example, `#: int`.\n\nType hints are added inline per member of the struct. For example:\n\n```cairo-lang\nstruct UserMeta:\n    member index : felt #: int\n    member hash : felt\n    member position : Position\nend\n```\n\nMembers without a type hint will default to `string` for `felt` and the struct type for structs.\n\nThe above Cairo-lang example outputs:\n```json\n[\n   {\n      \"name\":\"UserMeta\",\n      \"members\":[\n         {\n            \"type\":\"int\",\n            \"name\":\"index\"\n         },\n         {\n            \"type\":\"string\",\n            \"name\":\"hash\"\n         },\n         {\n            \"type\":\"Position\",\n            \"name\":\"position\"\n         }\n      ],\n      \"type\":\"struct\"\n   }\n]\n```\n\n## Adding hints to functions\nFunction hint comments mimic Cairo-lang function type declarations and are placed as the first statement in a function body. For example:\n\n```\n#: (index : int, position : Position) -\u003e (user : User)\n```\n\n```cairo-lang\n@view\nfunc get_user_by_index {\n    syscall_ptr : felt*, pedersen_ptr : HashBuiltin*,\n    range_check_ptr\n    } (index : felt, position : Position) -\u003e (user : User):\n    #: (index : int, position : Position) -\u003e (user : User)\n    let (hash) = users_index_to_hash.read(index)\n    let (user) = get_user_by_hash(hash)\n    return (user = user)\nend\n```\n\nThe above Cairo-lang example outputs:\n\n```json\n[\n    {\n      \"name\":\"get_user_by_index\",\n      \"inputs\":[\n         {\n            \"type\":\"int\",\n            \"name\":\"index\"\n         },\n         {\n            \"type\":\"Position\",\n            \"name\":\"position\"\n         }\n      ],\n      \"outputs\":[\n         {\n            \"type\":\"User\",\n            \"name\":\"user\"\n         }\n      ],\n      \"type\":\"function\"\n   }\n]\n```\n\n## Development\n\nInstall and switch to python 3.9.x\n```bash\n$ pyenv install 3.9.9\n$ pyenv local 3.9.9\n```\n\nCreate a virtual environment and activate it\n```bash\n$ python -m venv env\n$ source venv/bin/activate\n```\n\nDo some awesome work!\n\n## Build and publish the package\n```bash\n$ python setup.py bdist_wheel sdist\n$ twine upload dist/*\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaymint%2Fcairo-type-hints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplaymint%2Fcairo-type-hints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaymint%2Fcairo-type-hints/lists"}