{"id":28299319,"url":"https://github.com/zianksm/solc-browserify","last_synced_at":"2025-08-02T12:06:29.216Z","repository":{"id":65150927,"uuid":"583889302","full_name":"zianksm/solc-browserify","owner":"zianksm","description":"Solidity Compiler for the browser","archived":false,"fork":false,"pushed_at":"2024-04-28T18:47:29.000Z","size":922,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-26T07:19:45.825Z","etag":null,"topics":["browserify","compiler","ethereum","solidity","typescript","web3","webworker"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/solc-browserify","language":"TypeScript","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/zianksm.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-12-31T10:28:25.000Z","updated_at":"2025-02-03T23:26:00.000Z","dependencies_parsed_at":"2023-02-04T02:04:31.076Z","dependency_job_id":"5e10ce0c-27ec-48fb-a98d-8ff162f6ce7e","html_url":"https://github.com/zianksm/solc-browserify","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":0.4067796610169492,"last_synced_commit":"a0f52a35b50751ab18a93ac102828e81f47129ad"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zianksm/solc-browserify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zianksm%2Fsolc-browserify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zianksm%2Fsolc-browserify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zianksm%2Fsolc-browserify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zianksm%2Fsolc-browserify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zianksm","download_url":"https://codeload.github.com/zianksm/solc-browserify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zianksm%2Fsolc-browserify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267283984,"owners_count":24064038,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["browserify","compiler","ethereum","solidity","typescript","web3","webworker"],"created_at":"2025-05-23T09:16:44.251Z","updated_at":"2025-08-02T12:06:29.208Z","avatar_url":"https://github.com/zianksm.png","language":"TypeScript","readme":"![](https://img.shields.io/badge/using%20solc-0.8.20-blue)\n\n# Solc Browserify\n\nSolidity Compiler for the browser. Powered by WebWorker.\n\n# About\n\nThis package is heavily inspired by [rexdavinci/browser-solidity-compiler](https://github.com/rexdavinci/browser-solidity-compiler).\n\n### **Why another package?**\n\nthis package uses a different method to initialize the compiler, it uses the bundled `solc/wrapper` module provided by solc.\n\n### **How it works**\n\nthis is accomplished by using a **dedicated web worker** and browserifying the `solc/wrapper` module, and then uploading the bundled module to npm. the worker then fetch the bundled wrapper module directly using `importScripts` from `unpkg(open-source cdn for npm)`. check the bundled module [here](https://www.npmjs.com/package/solc-wrapper-bundle).\n\n### **Why use the bundled wrapper ?**\n\nthe [rexdavinci/browser-solidity-compiler](https://github.com/rexdavinci/browser-solidity-compiler) uses the built-in wasm `cwrap` function to initialize the compiler. although this works, the initialized compiler does not support import callbacks, which is important when you are building complex smart contracts.\n\nby using the bundled native `solc/wrapper`, it enables custom import callbacks function. which then you can pass arbitrary but pure functions when initalizing the compiler.\n\nbut this came at a cost, because we use the bundled native `solc/wrapper`, we effectively can only wrap the same `solc` binary version as the bundled `solc/wrapper`. there is currently no effecient and easy way to bundle `solc/wrapper` on the fly. solc version will be displayed using a badge in the readme.\n\n# Usage\n\n## **Installation**\n\n```bash\nnpm i solc-browserify\n```\n\n### using yarn\n\n```bash\nyarn add solc-browserify\n```\n\n## **Import it in your app**\n\n```typescript\nimport {\n  Solc,\n  ImportCallbackFn,\n  ImportCallbackReturnType,\n} from \"solc-browserify\";\n```\n\n## **Create a new Compiler Instance**\n\n```typescript\nconst compiler = new Solc(callback? : (Solc: Solc) =\u003e any);\n```\n\n\u003e Note that when creating a new compiler instance, the newly created worker will fetch `solc/wrapper` bundle(~500 KB) and the `solc` binary(~8 MB).\n\n## **Compile**\n\n```typescript\nconst output = await compiler.compile(contract);\n```\n\n## **Support for Import Callback**\n\nthis package have support for passing import callback function to the compiler.\nnote that the import callback cannot be a closure, MUST be pure function, synchronous, and takes in exactly 1 parameter for the import path.\n\n### **Basic example using import callback**\n\n```typescript\nimport {\n  Solc,\n  ImportCallbackFn,\n  ImportCallbackReturnType,\n} from \"solc-browserify\";\n\nconst contract = `import \"lib.sol\";\n\ncontract C {\n\n    function f() public {\n         L.f();\n    }\n}`;\n\nconst callback: ImportCallbackFn = function (\n  path: string\n): ImportCallbackReturnType {\n  const libSol = `library L { function f() internal returns (uint) { return 7; }`;\n\n  let contract: ImportCallbackReturnType = null;\n\n  if (path === \"lib.sol\") {\n    contract = { contents: libSol };\n\n    return contract;\n  }\n\n  contract = {\n    error: `could not find source contract for ${path}`,\n  };\n\n  return contract;\n};\n\nasync function main() {\n  const solc = new Solc();\n  const contract = await solc.compile(contract, callback);\n}\n\nmain();\n```\n\n# Example\n\n[**Here**](https://zianksm.github.io/solc-browserify-example/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzianksm%2Fsolc-browserify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzianksm%2Fsolc-browserify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzianksm%2Fsolc-browserify/lists"}