Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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](https://github.com/ethereum/solc-js).

This version only supports versions of solidity compiler greater than 0.5.x+ but you can still use old pragmas, they should still maybe compile. Just update your solidity code if it's too old!


### [Demo app](https://s3.amazonaws.com/browser-solc.dappbench.com/index.html)

You should use browser-solc if you:
Expand All @@ -12,7 +15,7 @@ You should use browser-solc if you:
## Usage:
```html
<!-- Include this in your HTML page -->
<script src="http://code.dappbench.com/browser-solc.min.js" type="text/javascript"></script>
<script src="./browser-solc.min.js" type="text/javascript"></script>

```

Expand All @@ -31,8 +34,48 @@ BrowserSolc.loadVersion("soljson-v0.4.6+commit.2dabbdf0.js", function(compiler)
result = compiler.compile(source, optimize);
console.log(result);
});
```

//autoload the most recent compiler (asynchronously)
setupCompiler(){
var outerThis = this;
setTimeout(function(){
window.BrowserSolc.getVersions(function(soljsonSources, soljsonReleases) {
var compilerVersion = soljsonReleases[_.keys(soljsonReleases)[0]];
console.log("Browser-solc compiler version : " + compilerVersion);
window.BrowserSolc.loadVersion(compilerVersion, function(c) {
compiler = c;
outerThis.setState({statusMessage:"ready!"},function(){
console.log("Solc Version Loaded: " + compilerVersion);
});
});
});
},1000);
}

// setup your contract for compilation

let jsonContractSource = JSON.stringify({
language: 'Solidity',
sources: {
'Task': {
content: yourContractText,
},
},
settings: {
outputSelection: {
'*': {
'*': ['abi',"evm.bytecode"]
},
},
},
});

// compile your contact

var result = compiler.compile(jsonContractSource);


```

## Development
To build browser-solc.js, run `browserify src/index.js -g yo-yoify -o browser-solc.js; babel browser-solc.js --out-file browser-solc.js`
Expand Down
58 changes: 56 additions & 2 deletions browser-solc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading