Skip to content

Commit 0ee14a7

Browse files
GrandSchtroumpfaxic
authored andcommitted
Add readme for browser version
1 parent 1af3817 commit 0ee14a7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,34 @@ var translate = require('solc/translate')
208208
// assemblyJSON refers to the JSON of the given assembly and sourceCode is the source of which the assembly was generated from
209209
var output = translate.prettyPrintLegacyAssemblyJSON(assemblyJSON, sourceCode)
210210
```
211+
212+
## Browser Usage
213+
214+
Add the version of `solc` you want to use into `index.html`:
215+
216+
```html
217+
<script type="text/javascript" src="https://solc-bin.ethereum.org/bin/{{ SOLC VERSION }}.js"></script>
218+
```
219+
220+
(Alternatively use `https://solc-bin.ethereum.org/bin/soljson-latest.js` to get the latests version.)
221+
222+
This will load `solc` into the global variable `window.Module`. Then use this inside Javascript as:
223+
224+
```javascript
225+
var wrapper = requrie('solc/wrapper')
226+
var solc = wrapper(window.Module)
227+
228+
```
229+
230+
Or in ES6 syntax:
231+
```javascript
232+
import * as wrapper from 'solc/wrapper'
233+
const solc = wrapper(window.Module)
234+
```
235+
236+
Alternatively, to iterate the releases, one can load `list.js` from `solc-bin`:
237+
```html
238+
<script type="text/javascript" src="https://solc-bin.ethereum.org/bin/list.js"></script>
239+
```
240+
241+
This will result in two global variables, `windows.soljsonReleases` listing all releases and `window.soljsonSources` listing all nightly builds and releases.

0 commit comments

Comments
 (0)