{"id":18357206,"url":"https://github.com/nethermindeth/starknet-abi","last_synced_at":"2025-04-06T12:32:38.712Z","repository":{"id":229812903,"uuid":"777397396","full_name":"NethermindEth/starknet-abi","owner":"NethermindEth","description":"Python Abi Decoder for Starknet","archived":false,"fork":false,"pushed_at":"2025-03-06T03:14:41.000Z","size":2051,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T00:34:01.443Z","etag":null,"topics":["nubia"],"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/NethermindEth.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":"2024-03-25T19:22:02.000Z","updated_at":"2024-11-06T20:31:56.000Z","dependencies_parsed_at":"2024-07-20T17:47:44.014Z","dependency_job_id":"7e50d39b-a521-4037-a18e-1ef2e4002436","html_url":"https://github.com/NethermindEth/starknet-abi","commit_stats":null,"previous_names":["nethermindeth/starknet-abi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NethermindEth%2Fstarknet-abi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NethermindEth%2Fstarknet-abi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NethermindEth%2Fstarknet-abi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NethermindEth%2Fstarknet-abi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NethermindEth","download_url":"https://codeload.github.com/NethermindEth/starknet-abi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247484631,"owners_count":20946388,"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":["nubia"],"created_at":"2024-11-05T22:13:13.200Z","updated_at":"2025-04-06T12:32:33.701Z","avatar_url":"https://github.com/NethermindEth.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Starknet ABI\n\nStarknet ABI is a Python library for encoding and decoding Starknet contract calls and events. It is built for efficient and rapid indexing of Starknet transactions, offering simplicity and speed.\n\n## Documentation\n### [Starknet-ABI Docs](https://nethermindeth.github.io/starknet-abi)\n\n\n## Features\n\n- **Encode and Decode**: Easily encode and decode Starknet contract calls and events.\n- **Comprehensive Parsing**: Parse all versions of Cairo ABI JSON into a shared data structure.\n- **Type Identification**: Identify type strings for each function, enabling the detection of ABIs with identical types.\n- **ABI Decoding Dispatcher**:\n  - Efficiently load thousands of indexed ABIs into memory.\n  - Pickle and reuse the decoding dispatcher data structure in data pipelines.\n\n## Contributing\n\nWe value community contributions and are eager to support your involvement. If you encounter any bugs or have suggestions for new features, please [open an issue](https://github.com/NethermindEth/starknet-abi/issues/new) or submit a [pull request](https://github.com/NethermindEth/starknet-abi/pulls).\n\n## Installation\nOnce the library is stable, builds will be published to PyPi. In the meantime, you can install as git+ package\n\n```bash\n# pip install\npip install git+https://github.com/NethermindEth/starknet-abi.git\n\n# add as Poetry dependency\npoetry add git+https://github.com/NethermindEth/starknet-abi.git\n```\n\n## Development Installation\n```bash\ngit clone https://github.com/nethermindEth/starknet-abi\ncd starknet-abi\npoetry env use python3.12  # Supports any version of python \u003e= 3.10, but 3.12 is the fastest\npoetry install --all-extras\n```\n\n## Quickstart\n\n### Parse Starknet ABI JSON\n\n1. Get the [Starknet-ETH ABI JSON](https://voyager.online/class/0x05ffbcfeb50d200a0677c48a129a11245a3fc519d1d98d76882d1c9a1b19c6ed) from Voyager and save it to a file named `abi.json`.\n2. Create a `StarknetABI` instance from the ABI JSON file:\n\n```python\nimport json\nfrom nethermind.starknet_abi.core import StarknetAbi\n\nwith open(\"abi.json\") as f:\n    raw_abi = json.load(f)\n\n# Create a StarknetABI instance\nstarknet_eth_abi = StarknetAbi.from_json(raw_abi, \"starknet_eth\", b\"\")\n\n# View the ABI functions\nprint(starknet_eth_abi.functions)\n\n# View the ABI implemented interfaces\nprint(starknet_eth_abi.implemented_interfaces)\n```\n\n### Decode transaction calldata\n\n1. Decode core types:\n\n```python\n\u003e\u003e\u003e from nethermind.starknet_abi.decode import decode_core_type, StarknetCoreType\n\u003e\u003e\u003e decode_core_type(StarknetCoreType.Bool, [0])\nFalse\n\u003e\u003e\u003e decode_core_type(StarknetCoreType.U256, [12345, 0])\n12345\n\u003e\u003e\u003e decode_core_type(StarknetCoreType.Felt, [256])\n'0x0000000000000000000000000000000000000000000000000000000000000100'\n```\n\n2. Decode from parameters:\n\n```python\n\u003e\u003e\u003e from nethermind.starknet_abi.decode import decode_from_params, StarknetCoreType, AbiParameter\n\u003e\u003e\u003e decode_from_params(\n        [AbiParameter(\"a\", StarknetCoreType.U32), AbiParameter(\"b\", StarknetCoreType.U32)],\n        [123456, 654321]\n    )\n{'a': 123456, 'b': 654321}\n```\n\n3. Decode from types:\n\n```python\n\u003e\u003e\u003e from nethermind.starknet_abi.decode import decode_from_types, StarknetCoreType, StarknetArray\n\u003e\u003e\u003e decode_from_types([StarknetArray(StarknetCoreType.U8), StarknetCoreType.Bool], [3, 123, 244, 210, 0])\n[[123, 244, 210], False]\n\u003e\u003e\u003e decode_from_types(\n        [StarknetCoreType.ContractAddress, StarknetCoreType.U256, StarknetCoreType.Bool],\n        [0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7, 250_000, 0, 1]\n    )\n['0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', 250000, True]\n```\n\n### Encode transaction calldata\n\n1. Encode core types:\n\n```python\n\u003e\u003e\u003e from nethermind.starknet_abi.encode import encode_core_type, StarknetCoreType\n\u003e\u003e\u003e encode_core_type(StarknetCoreType.Bool, False)\n[0]\n\u003e\u003e\u003e encode_core_type(StarknetCoreType.U256, 12345)\n[12345, 0]\n\u003e\u003e\u003e encode_core_type(StarknetCoreType.Felt, \"0x0000000000000000000000000000000000000000000000000000000000000100\")\n[256]\n```\n\n2. Encode from parameters:\n\n```python\n\u003e\u003e\u003e from nethermind.starknet_abi.encode import encode_from_params, StarknetCoreType, AbiParameter\n\u003e\u003e\u003e encode_from_params(\n        [AbiParameter(\"a\", StarknetCoreType.U32), AbiParameter(\"b\", StarknetCoreType.U32)],\n        {\"a\": 123456, \"b\": 654321}\n    )\n[123456, 654321]\n```\n\n3. Encode from types:\n\n```python\n\u003e\u003e\u003e from nethermind.starknet_abi.encode import encode_from_types, StarknetCoreType, StarknetArray\n\u003e\u003e\u003e encode_from_types([StarknetArray(StarknetCoreType.U8), StarknetCoreType.Bool], [[123, 244, 210], False])\n[3, 123, 244, 210, 0]\n\u003e\u003e\u003e encode_from_types(\n        [StarknetCoreType.ContractAddress, StarknetCoreType.U256, StarknetCoreType.Bool],\n        [\"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7\", 250000, True]\n    )\n[2087021424722619777119509474943472645767659996348769578120564519014510906823, 250000, 0, 1]\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnethermindeth%2Fstarknet-abi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnethermindeth%2Fstarknet-abi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnethermindeth%2Fstarknet-abi/lists"}