Skip to content

Commit acf0fe7

Browse files
committed
Expose the lowlevel compile API
1 parent 6b6adad commit acf0fe7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ There is also a direct method, `compileStandard`, which is only present on recen
105105

106106
Starting from version 0.4.20 a Semver compatible version number can be retrieved on every compiler release, including old ones, using the `semver()` method.
107107

108+
#### From version 0.5.0
109+
110+
Starting from version 0.5.0 the low-level functions are also exposed:
111+
- `solc.lowlevel.compileSingle`: the original entry point, supports only a single file
112+
- `solc.lowlevel.compileMulti`: this supports multiple files, introduced in 0.1.6
113+
- `solc.lowlevel.compileCallback`: this supports callbacks, introduced in 0.2.1
114+
- `solc.lowlevel.compileStandard`: this supports the Standard JSON input and output interface, introduced in 0.4.11
115+
116+
Example:
117+
```javascript
118+
var solc = require('solc')
119+
var input = {
120+
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',
121+
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
122+
}
123+
var output = JSON.parse(solc.lowlevel.compileMulti(JSON.stringify({ sources: input }), 1))
124+
for (var contractName in output.contracts)
125+
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
126+
```
127+
108128
### Using with Electron
109129

110130
**Note:**

wrapper.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ function setupMethods (soljson) {
223223
version: version,
224224
semver: versionToSemver,
225225
license: license,
226+
lowlevel: {
227+
compileSingle: compileJSON,
228+
compileMulti: compileJSONMulti,
229+
compileCallback: compileJSONCallback,
230+
compileStandard: compileStandard
231+
},
226232
compile: compile,
227233
compileStandard: compileStandard,
228234
compileStandardWrapper: compileStandardWrapper,

0 commit comments

Comments
 (0)