browser-solc

Solidity compiler in the browser

View the Project on GitHub ericxtang/browser-solc

Solidity Compiler In the Browser

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:

Include this in your code

<script src="http://code.dappbench.com/browser-solc.min.js" type="text/javascript"></script>

Usage

//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);
}