browser-solc
v1.0.0
Published
A wrapper of solc so that you can compile contracts in the browser
Downloads
62
Maintainers
Readme
browser-solc
About the fork
Forked from https://github.com/ericxtang/browser-solc to wrap it into a npm package so that it can be easily imported into a Webpack (or another bundler) web app.
Solc
Solc is the solidity compiler. It usually runs on the Ethereum node. Browser-solidity is an example for Solc in the browser, but it's hard to pick apart just the solc library from the entire application. This repo is a wrapper that helps you do that. browser-solc is a browserified version of solc-js.
#Demo app
You should use browser-solc if you:
- Want to do
solc.compile()
in your Dapp - Don't want to worry about browserify the solc-js npm package
Installation
npm install --save browser-solc
Usage:
import browserSolc from 'browser-solc';
// After importing, the BrowserSolc will be loaded into the window object. This is required as it was built with browserify.
//Get a list of all possibile solc versions
BrowserSolc.getVersions(function(soljsonSources, soljsonReleases) {
console.log(soljsonSources);
console.log(soljsonReleases);
});
//Load a specific compiler version
BrowserSolc.loadVersion("soljson-v0.4.6+commit.2dabbdf0.js", function(compiler) {
source = 'contract x { function g() {} }';
optimize = 1;
result = compiler.compile(source, optimize);
console.log(result);
});
Development
To build index.js
, run npm run build
.
Note: browser-solc does NOT implement the whole interface of solc-js.