{"id":20392374,"url":"https://github.com/wiseplat/npm2-solc","last_synced_at":"2025-03-05T00:21:37.123Z","repository":{"id":122792560,"uuid":"130826638","full_name":"WISEPLAT/npm2-solc","owner":"WISEPLAT","description":"Solidity compiler","archived":false,"fork":false,"pushed_at":"2018-04-24T09:08:11.000Z","size":1532,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-15T10:26:25.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/WISEPLAT.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":"2018-04-24T09:04:54.000Z","updated_at":"2018-04-24T09:08:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"684db0c0-ca15-4d56-bbd8-aa75184530dc","html_url":"https://github.com/WISEPLAT/npm2-solc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fnpm2-solc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fnpm2-solc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fnpm2-solc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fnpm2-solc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WISEPLAT","download_url":"https://codeload.github.com/WISEPLAT/npm2-solc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241941711,"owners_count":20046172,"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":[],"created_at":"2024-11-15T03:43:34.260Z","updated_at":"2025-03-05T00:21:37.112Z","avatar_url":"https://github.com/WISEPLAT.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/wiseplat/solc-js.svg?branch=master)](https://travis-ci.org/wiseplat/solc-js)\n\n# solc-js\nJavaScript bindings for the [Solidity compiler](https://github.com/wiseplat/solidity).\n\nUses the Emscripten compiled Solidity found in the [solc-bin repository](https://github.com/wiseplat/solc-bin).\n\n## Node.js Usage\n\nTo use the latest stable version of the Solidity compiler via Node.js you can install it via npm:\n\n```bash\nnpm install solc\n```\n\n### Usage on the Command-Line\n\nIf this package is installed globally (`npm install -g solc`), a command-line tool called `solcjs` will be available.\n\nTo see all the supported features, execute:\n\n```bash\nsolcjs --help\n```\n\nNote: this commandline interface is not compatible with `solc` provided by the Solidity compiler package and thus cannot be\nused in combination with an Wiseplat client via the `wsh.compile.solidity()` RPC method. Please refer to the\n[Solidity compiler documentation](https://solidity.readthedocs.io/) for instructions to install `solc`.\n\n### Usage in Projects\n\n#### From early versions\n\nIt can also be included and used in other projects:\n\n```javascript\nvar solc = require('npm2-solc')\nvar input = 'contract x { function g() {} }'\n// Setting 1 as second paramateractivates the optimiser\nvar output = solc.compile(input, 1)\nfor (var contractName in output.contracts) {\n\t// code and ABI that are needed by web3\n\tconsole.log(contractName + ': ' + output.contracts[contractName].bytecode)\n\tconsole.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface))\n}\n```\n\n#### From version 0.1.6\n\nStarting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:\n\n```javascript\nvar solc = require('npm2-solc')\nvar input = {\n\t'lib.sol': 'library L { function f() returns (uint) { return 7; } }',\n\t'cont.sol': 'import \"lib.sol\"; contract x { function g() { L.f(); } }'\n}\nvar output = solc.compile({ sources: input }, 1)\nfor (var contractName in output.contracts)\n\tconsole.log(contractName + ': ' + output.contracts[contractName].bytecode)\n```\n\nNote that all input files that are imported have to be supplied, the compiler will not load any additional files on its own.\n\n#### From version 0.2.1\n\nStarting from version 0.2.1, a callback is supported to resolve missing imports as follows:\n\n```javascript\nvar solc = require('npm2-solc')\nvar input = {\n\t'cont.sol': 'import \"lib.sol\"; contract x { function g() { L.f(); } }'\n}\nfunction findImports (path) {\n\tif (path === 'lib.sol')\n\t\treturn { contents: 'library L { function f() returns (uint) { return 7; } }' }\n\telse\n\t\treturn { error: 'File not found' }\n}\nvar output = solc.compile({ sources: input }, 1, findImports)\nfor (var contractName in output.contracts)\n\tconsole.log(contractName + ': ' + output.contracts[contractName].bytecode)\n```\n\nThe `compile()` method always returns an object, which can contain `errors`, `sources` and `contracts` fields. `errors` is a list of error mesages.\n\n#### From version 0.4.11\n\nStarting from version 0.4.11 there is a new entry point named `compileStandardWrapper()` which supports Solidity's [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description). It also maps old compiler output to it.\n\n### Using with Electron\n\n**Note:**\nIf you are using Electron, `nodeIntegration` is on for `BrowserWindow` by default. If it is on, Electron will provide a `require` method which will not behave as expected and this may cause calls, such as `require('npm2-solc')`, to fail.\n\nTo turn off `nodeIntegration`, use the following:\n\n```javascript\nnew BrowserWindow({\n\twebPreferences: {\n\t\tnodeIntegration: false\n\t}\n})\n```\n\n### Using a Legacy Version\n\nIn order to compile contracts using a specific version of Solidity, the `solc.loadRemoteVersion(version, callback)` method is available. This returns a new `solc` object that uses a version of the compiler specified. \n\nYou can also load the \"binary\" manually and use `setupMethods` to create the familiar wrapper functions described above:\n`var solc = solc.setupMethods(require(\"/my/local/soljson.js\"))`.\n\n### Using the Latest Development Snapshot\n\nBy default, the npm version is only created for releases. This prevents people from deploying contracts with non-release versions because they are less stable and harder to verify. If you would like to use the latest development snapshot (at your own risk!), you may use the following example code.\n\n```javascript\nvar solc = require('npm2-solc')\n\n// getting the development snapshot\nsolc.loadRemoteVersion('latest', function (err, solcSnapshot) {\n\tif (err) {\n\t\t// An error was encountered, display and quit\n\t}\n\tvar output = solcSnapshot.compile(\"contract t { function g() {} }\", 1)\n})\n```\n\n### Linking Bytecode\n\nWhen using libraries, the resulting bytecode will contain placeholders for the real addresses of the referenced libraries. These have to be updated, via a process called linking, before deploying the contract.\n\nThe `linkBytecode` method provides a simple helper for linking:\n\n```javascript\nbytecode = solc.linkBytecode(bytecode, { 'MyLibrary': '0x123456...' })\n```\n\nNote: in future versions of Solidity a more sophisticated linker architecture will be introduced.  Once that changes, this method will still be usable for output created by old versions of Solidity.\n\n### Updating the ABI\n\nThe ABI generated by Solidity versions can differ slightly, due to new features introduced.  There is a tool included which aims to translate the ABI generated by an older Solidity version to conform to the latest standard.\n\nIt can be used as:\n```javascript\nvar abi = require('solc/abi')\n\nvar inputABI = [{\"constant\":false,\"inputs\":[],\"name\":\"hello\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"}]\nvar outputABI = abi.update('0.3.6', inputABI)\n// Output contains: [{\"constant\":false,\"inputs\":[],\"name\":\"hello\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":true,\"type\":\"function\"},{\"type\":\"fallback\",\"payable\":true}]\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseplat%2Fnpm2-solc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiseplat%2Fnpm2-solc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseplat%2Fnpm2-solc/lists"}