Skip to content

dmerrill6/browser-solc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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.

About

A wrapper of solc so that you can compile contracts in the browser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.5%
  • HTML 0.5%