From 0ee14a71eedd2667c1fad5c3a38ceebc0fc50a34 Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Fri, 7 Dec 2018 16:08:04 +0100 Subject: [PATCH] Add readme for browser version --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index b0a3d5c2..4cba8ab8 100644 --- a/README.md +++ b/README.md @@ -208,3 +208,34 @@ var translate = require('solc/translate') // assemblyJSON refers to the JSON of the given assembly and sourceCode is the source of which the assembly was generated from var output = translate.prettyPrintLegacyAssemblyJSON(assemblyJSON, sourceCode) ``` + +## Browser Usage + +Add the version of `solc` you want to use into `index.html`: + +```html + +``` + +(Alternatively use `https://solc-bin.ethereum.org/bin/soljson-latest.js` to get the latests version.) + +This will load `solc` into the global variable `window.Module`. Then use this inside Javascript as: + +```javascript +var wrapper = requrie('solc/wrapper') +var solc = wrapper(window.Module) + +``` + +Or in ES6 syntax: +```javascript +import * as wrapper from 'solc/wrapper' +const solc = wrapper(window.Module) +``` + +Alternatively, to iterate the releases, one can load `list.js` from `solc-bin`: +```html + +``` + +This will result in two global variables, `windows.soljsonReleases` listing all releases and `window.soljsonSources` listing all nightly builds and releases.