{"id":18577168,"url":"https://github.com/sbip-sg/solc-json-parser","last_synced_at":"2025-04-10T09:30:46.796Z","repository":{"id":79926769,"uuid":"541943446","full_name":"sbip-sg/solc-json-parser","owner":"sbip-sg","description":" A Powerful AST Parser for Solidity","archived":false,"fork":false,"pushed_at":"2024-09-20T08:24:56.000Z","size":2007,"stargazers_count":11,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T13:31:06.763Z","etag":null,"topics":["ast","ethereum","evm","parser","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbip-sg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-09-27T06:49:53.000Z","updated_at":"2024-12-27T11:41:28.000Z","dependencies_parsed_at":"2024-06-11T11:02:52.701Z","dependency_job_id":null,"html_url":"https://github.com/sbip-sg/solc-json-parser","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbip-sg%2Fsolc-json-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbip-sg%2Fsolc-json-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbip-sg%2Fsolc-json-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbip-sg%2Fsolc-json-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbip-sg","download_url":"https://codeload.github.com/sbip-sg/solc-json-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994108,"owners_count":21030049,"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":["ast","ethereum","evm","parser","solidity"],"created_at":"2024-11-06T23:28:04.079Z","updated_at":"2025-04-10T09:30:45.227Z","avatar_url":"https://github.com/sbip-sg.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# An AST parser for solc json outputs\n\nParsing AST with solidity source code and get contract information.\n\n## Quickstart\n\n### Installation\n\nClone this repository and install it with pip:\n\n``` bash\ngit clone https://github.com/sbip-sg/solc-json-parser.git\ncd solc-json-parser\npip install .\n```\n\n### Usage\n\nExample usage using [standard json](https://docs.soliditylang.org/en/v0.8.17/using-the-compiler.html#compiler-input-and-output-json-description):\n\n``` python\nimport json\nfrom solc_json_parser.standard_json_parser import StandardJsonParser\nwith open('contracts/standard_json/75b8.standard-input.json') as f:\n    input_json = json.load(f)\n\nversion = '0.8.4'\nparser = StandardJsonParser(input_json, version)\n\n# Get all contract names\nparser.all_contract_names\n# ['IERC1271',\n#  ...\n#  'ContractKeys',\n#  'NFTfiSigningUtils',\n#  'NftReceiver',\n#  'Ownable']\n\n# Get source code by PC\nsource = parser.source_by_pc('DirectLoanFixedOffer', 13232)\nsource\n# {'pc': 13232,\n#  'linenums': [921, 924],\n#  'fragment': 'LoanChecksAndCalculations.computeRevenueShare(\\n            adminFee,\\n            loanExtras.revenueShareInBasisPoints\\n        )',\n#  'fid': 'contracts/loans/direct/loanTypes/DirectLoanBaseMinimal.sol',\n#  'begin': 45007,\n#  'end': 45134,\n#  'source_idx': 26,\n#  'source_path': 'contracts/loans/direct/loanTypes/DirectLoanBaseMinimal.sol'}\n\n# Get function AST unit by PC\nfunc = parser.function_unit_by_pc('DirectLoanFixedOffer', 13232)\n# Parameter names of this function\n[n.get('name') for n in func.get('parameters').get('parameters')]\n# ['_loanId', '_borrower', '_lender', '_loan']\n# Function selector, available only for external or public functions\nfunc.get('functionSelector')\n\n# Get the innermost AST unit by PC\nparser.ast_unit_by_pc('DirectLoanFixedOffer', 13232)\n```\n\n## Command line tools\n\n``` bash\nsolc-json-parser --help\n```\n\nDecode binary to opcodes:\n\n``` bash\n❯ solc-json-parser dp 0x60806040525f80fdfea26469706673582212200466fd4ed0d73499199c39545f7019da158defa354cc0051afe02754ec8e32b464736f6c63430008180033\nPUSH1 0x80\nPUSH1 0x40\nMSTORE\nPUSH0 0x\nDUP1\nREVERT\nINVALID\nLOG2\nPUSH5 0x6970667358\n0X22\nSLT\nSHA3\nDIV\nPUSH7 0xfd4ed0d7349919\nSWAP13\n...\n```\n\n\n\n## Note\n\n- This library only supports detecting Solidity version newer than or equal to\n  `v0.4.11`. This is due to the limitation of the base library [py-solc-x](https://solcx.readthedocs.io/en/latest/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbip-sg%2Fsolc-json-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbip-sg%2Fsolc-json-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbip-sg%2Fsolc-json-parser/lists"}