You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting from version 0.5.0, `compile`, `compileStandard` and `compileStandardWrapper` all do the same thing - what `compileStandardWrapper` used to do.
51
37
52
-
**Not available since 0.5.0**
38
+
*Note*: with 0.5.2, `compileStandard` and `compileStandardWrapper` will be removed.
53
39
54
-
Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:
40
+
Starting from version 0.5.0 the low-level functions are also exposed:
41
+
-`solc.lowlevel.compileSingle`: the original entry point, supports only a single file
42
+
-`solc.lowlevel.compileMulti`: this supports multiple files, introduced in 0.1.6
43
+
-`solc.lowlevel.compileCallback`: this supports callbacks, introduced in 0.2.1
44
+
-`solc.lowlevel.compileStandard`: this supports the Standard JSON input and output interface, introduced in 0.4.11
55
45
46
+
Example:
56
47
```javascript
57
48
var solc =require('solc')
58
49
var input = {
59
50
'lib.sol':'library L { function f() returns (uint) { return 7; } }',
60
51
'cont.sol':'import "lib.sol"; contract x { function g() { L.f(); } }'
61
52
}
62
-
var output =solc.compile({ sources: input }, 1)
53
+
var output =JSON.parse(solc.lowlevel.compileMulti(JSON.stringify({ sources: input }), 1))
Note that all input files that are imported have to be supplied, the compiler will not load any additional files on its own.
58
+
#### From version 0.4.20
59
+
60
+
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.
61
+
62
+
#### From version 0.4.11
63
+
64
+
Starting from version 0.4.11 there is a new entry point named `compileStandardWrapper()` which supports Solidity's [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description). It also maps old compiler output to it.
65
+
66
+
```javascript
67
+
var solc =require('solc')
68
+
69
+
// 'input' is a JSON string corresponding to the "standard JSON input" as described in the link above
70
+
// 'findImports' works as described above
71
+
var output =solc.compileStandardWrapper(input, findImports)
72
+
// Ouput is a JSON string corresponding to the "standard JSON output"
73
+
```
74
+
75
+
There is also a direct method, `compileStandard`, which is only present on recent compilers and works the same way. `compileStandardWrapper` is preferred however because it provides the same interface for old compilers.
68
76
69
77
#### From version 0.2.1
70
78
@@ -90,47 +98,40 @@ for (var contractName in output.contracts)
90
98
91
99
The `compile()` method always returns an object, which can contain `errors`, `sources` and `contracts` fields. `errors` is a list of error mesages.
92
100
93
-
#### From version 0.4.11
101
+
#### From version 0.1.6
94
102
95
-
Starting from version 0.4.11 there is a new entry point named `compileStandardWrapper()` which supports Solidity's [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description). It also maps old compiler output to it.
103
+
**Not available since 0.5.0**
104
+
105
+
Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:
96
106
97
107
```javascript
98
108
var solc =require('solc')
99
-
100
-
// 'input' is a JSON string corresponding to the "standard JSON input" as described in the link above
101
-
// 'findImports' works as described above
102
-
var output =solc.compileStandardWrapper(input, findImports)
103
-
// Ouput is a JSON string corresponding to the "standard JSON output"
109
+
var input = {
110
+
'lib.sol':'library L { function f() returns (uint) { return 7; } }',
111
+
'cont.sol':'import "lib.sol"; contract x { function g() { L.f(); } }'
There is also a direct method, `compileStandard`, which is only present on recent compilers and works the same way. `compileStandardWrapper` is preferred however because it provides the same interface for old compilers.
107
-
108
-
#### From version 0.4.20
109
-
110
-
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.
111
-
112
-
#### From version 0.5.0
118
+
Note that all input files that are imported have to be supplied, the compiler will not load any additional files on its own.
113
119
114
-
Starting from version 0.5.0, `compile`, `compileStandard` and `compileStandardWrapper` all do the same thing - what `compileStandardWrapper` used to do.
115
120
116
-
*Note*: with 0.5.1, `compileStandard` and `compileStandardWrapper` will be removed.
121
+
#### From early versions
117
122
118
-
Starting from version 0.5.0 the low-level functions are also exposed:
119
-
-`solc.lowlevel.compileSingle`: the original entry point, supports only a single file
120
-
-`solc.lowlevel.compileMulti`: this supports multiple files, introduced in 0.1.6
121
-
-`solc.lowlevel.compileCallback`: this supports callbacks, introduced in 0.2.1
122
-
-`solc.lowlevel.compileStandard`: this supports the Standard JSON input and output interface, introduced in 0.4.11
123
+
It can also be included and used in other projects:
123
124
124
-
Example:
125
125
```javascript
126
126
var solc =require('solc')
127
-
var input = {
128
-
'lib.sol':'library L { function f() returns (uint) { return 7; } }',
129
-
'cont.sol':'import "lib.sol"; contract x { function g() { L.f(); } }'
130
-
}
131
-
var output =JSON.parse(solc.lowlevel.compileMulti(JSON.stringify({ sources: input }), 1))
132
-
for (var contractName inoutput.contracts)
127
+
var input ='contract x { function g() {} }'
128
+
// Setting 1 as second paramater activates the optimiser
0 commit comments