{"id":14035,"library":"solidity-parser-sc","title":"Solidity PEG.js Parser (Abandoned)","description":"solidity-parser-sc is an unmaintained JavaScript parser for Solidity, built using PEG.js. Last published in June 2018 with version 0.4.12, it is based on an older version of the `consensys/solidity-parser` with specific grammar rules, notably adding support for Gnosis-style interpolation (e.g., `{{Variable}}`) to defer address assignments. Due to its age and lack of maintenance (last update over 8 years ago), it does not support modern Solidity syntax or language features, and its parsing behavior may not conform to the current official Solidity specification. There is no active release cadence, and it is considered abandoned. For any current or new projects requiring robust and up-to-date Solidity parsing, developers are strongly advised to use `@solidity-parser/parser` (latest version 0.20.2), which is an actively maintained ANTLR4-based parser that provides comprehensive support for the evolving Solidity language.","status":"abandoned","version":"0.4.12","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install solidity-parser-sc","lang":"bash","label":"npm"},{"cmd":"yarn add solidity-parser-sc","lang":"bash","label":"yarn"},{"cmd":"pnpm add solidity-parser-sc","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package predates widespread ESM adoption and primarily uses CommonJS `require()`. It exports a default object containing the `parse` method.","wrong":"import { parse } from 'solidity-parser-sc';","symbol":"parse","correct":"const parser = require('solidity-parser-sc');\nconst ast = parser.parse(solidityCode);"},{"note":"A ParserError class is typically exported for custom error handling. This is an assumed export pattern based on similar parser libraries from the era.","symbol":"ParserError","correct":"const { ParserError } = require('solidity-parser-sc');\n// ... catch (e) { if (e instanceof ParserError) { ... } }"}],"quickstart":{"code":"const parser = require('solidity-parser-sc');\n\nconst solidityCode = `\npragma solidity ^0.4.0;\n\ncontract SimpleStorage {\n    uint256 public storedData;\n\n    event DataStored(uint256 indexed oldValue, uint256 indexed newValue);\n\n    function set(uint256 x) public {\n        emit DataStored(storedData, x);\n        storedData = x;\n    }\n\n    function get() public view returns (uint256) {\n        return storedData;\n    }\n}\n`;\n\ntry {\n    const ast = parser.parse(solidityCode, { tolerant: true, loc: true });\n    console.log('Successfully parsed Solidity code.');\n    // console.log(JSON.stringify(ast, null, 2)); // Uncomment to see the full AST\n\n    // Example: Find contract names\n    const contractDefinitions = ast.children.filter(node => node.type === 'ContractDefinition');\n    if (contractDefinitions.length > 0) {\n        console.log(`Found contract: ${contractDefinitions[0].name}`);\n    } else {\n        console.log('No contract definition found.');\n    }\n} catch (e) {\n    if (e instanceof parser.ParserError) {\n        console.error('Solidity Parsing Error:');\n        e.errors.forEach(err => console.error(` - ${err.message} (Line: ${err.line}, Column: ${err.column})`));\n    } else {\n        console.error('An unexpected error occurred:', e.message);\n    }\n}","lang":"javascript","description":"This quickstart demonstrates how to parse a simple Solidity contract using `solidity-parser-sc` and extract a contract definition from the resulting Abstract Syntax Tree (AST)."},"warnings":[{"fix":"Migrate to an actively maintained Solidity parser such as `@solidity-parser/parser`. Install it via `npm install @solidity-parser/parser` and update your import statements and parsing logic accordingly.","message":"This package is effectively abandoned. Its last update was in June 2018 (v0.4.12), meaning it does not support any Solidity syntax or features introduced since Solidity 0.4.x. Attempting to parse modern Solidity code (e.g., Solidity 0.5.x and above) will likely result in parsing errors or an incorrect AST.","severity":"breaking","affected_versions":">=0.4.13"},{"fix":"Evaluate if the Gnosis interpolation is still critical. If so, consider a pre-parsing step to resolve these interpolations before feeding the code to a standard Solidity parser. If not, remove the non-standard syntax from your contracts.","message":"The package's primary differentiating feature was support for Gnosis-specific `{{Variable}}` interpolation syntax. If your project relies on this specific syntax, migrating away might require pre-processing your Solidity code or finding an alternative solution, as standard Solidity parsers do not support this non-standard syntax natively.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Transition to a parser based on a modern grammar parsing framework like ANTLR4 to ensure compatibility and ongoing support with Solidity language evolution. `@solidity-parser/parser` is the recommended successor.","message":"This library uses PEG.js, an older parser generator. Modern Solidity parsers like `@solidity-parser/parser` utilize ANTLR4, which is generally more robust and easier to maintain for complex, evolving grammars like Solidity. Using this outdated technology stack means it's highly unlikely to receive updates for new Solidity versions.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'/parser':127 '0.20.2':130 '0.4.12':26 '2018':23 '8':66 'abandon':4,102 'activ':95,134 'ad':42 'address':53 'advis':121 'age':58 'ago':68 'antlr4':137 'antlr4-based':136 'assign':54 'base':29,138 'behavior':82 'built':16 'cadenc':97 'comprehens':142 'conform':85 'consensys/solidity-parser':36 'consid':101 'current':88,105 'date':115 'defer':52 'develop':118 'due':55 'e.g':49 'evolv':146 'featur':78 'gnosi':46 'gnosis-styl':45 'grammar':39 'interpol':48 'javascript':12,149 'june':22 'lack':60 'languag':77,148 'last':19,63 'latest':128 'maintain':135 'mainten':62 'may':83 'modern':73 'new':107 'notabl':41 'offici':89 'older':32 'pars':81,117 'parser':3,7,13,126,139 'peg.js':2,18 'project':108 'provid':141 'publish':20 'releas':96 'requir':109 'robust':110 'rule':40 'sc':8 'solid':1,6,15,74,90,116,125,147 'solidity-pars':124 'solidity-parser-sc':5 'specif':38,91 'strong':120 'style':47 'support':43,72,143 'syntax':75 'unmaintain':11 'up-to-d':112 'updat':64 'use':17,123 'variabl':50 'version':25,33,129 'year':67","created_at":"2026-04-20T01:57:35.959245+00:00","updated_at":"2026-04-20T01:57:35.959245+00:00","problems":[{"fix":"Ensure the Solidity code adheres to a very old Solidity standard (e.g., 0.4.x). For modern Solidity, this parser is inadequate; switch to `@solidity-parser/parser`.","cause":"This error often indicates that the Solidity code contains syntax that is not recognized by the parser's outdated grammar, or there's a malformed token. It's highly probable with Solidity versions >0.4.x.","error":"SyntaxError: Expected \"}\", \"\\n\", \"\\r\", or end of input but \"p\" found."},{"fix":"Verify the import statement is `const parser = require('solidity-parser-sc');` and that `parser.parse()` is being called. If the error persists, the installation might be corrupted or the package structure differs from common patterns.","cause":"This error typically occurs if the package was incorrectly imported or if the module itself did not export the `parse` function as expected. Given its age, CommonJS `require` is the correct import method.","error":"TypeError: Cannot read property 'parse' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/solidity-parser-sc","openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}