Skip to content

Commit ac6319d

Browse files
committed
Reorder README to have newest versions on top
1 parent 0022a7c commit ac6319d

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

README.md

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,48 @@ used in combination with an Ethereum client via the `eth.compile.solidity()` RPC
3131

3232
### Usage in Projects
3333

34-
#### From early versions
35-
36-
It can also be included and used in other projects:
37-
38-
```javascript
39-
var solc = require('solc')
40-
var input = 'contract x { function g() {} }'
41-
// Setting 1 as second paramater activates the optimiser
42-
var output = solc.compile(input, 1)
43-
for (var contractName in output.contracts) {
44-
// code and ABI that are needed by web3
45-
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
46-
console.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface))
47-
}
48-
```
34+
#### From version 0.5.0
4935

50-
#### From version 0.1.6
36+
Starting from version 0.5.0, `compile`, `compileStandard` and `compileStandardWrapper` all do the same thing - what `compileStandardWrapper` used to do.
5137

52-
**Not available since 0.5.0**
38+
*Note*: with 0.5.1, `compileStandard` and `compileStandardWrapper` will be removed.
5339

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
5545

46+
Example:
5647
```javascript
5748
var solc = require('solc')
5849
var input = {
5950
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',
6051
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
6152
}
62-
var output = solc.compile({ sources: input }, 1)
53+
var output = JSON.parse(solc.lowlevel.compileMulti(JSON.stringify({ sources: input }), 1))
6354
for (var contractName in output.contracts)
6455
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
6556
```
6657

67-
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.
6876

6977
#### From version 0.2.1
7078

@@ -90,47 +98,40 @@ for (var contractName in output.contracts)
9098

9199
The `compile()` method always returns an object, which can contain `errors`, `sources` and `contracts` fields. `errors` is a list of error mesages.
92100

93-
#### From version 0.4.11
101+
#### From version 0.1.6
94102

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:
96106

97107
```javascript
98108
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(); } }'
112+
}
113+
var output = solc.compile({ sources: input }, 1)
114+
for (var contractName in output.contracts)
115+
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
104116
```
105117

106-
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.
113119

114-
Starting from version 0.5.0, `compile`, `compileStandard` and `compileStandardWrapper` all do the same thing - what `compileStandardWrapper` used to do.
115120

116-
*Note*: with 0.5.1, `compileStandard` and `compileStandardWrapper` will be removed.
121+
#### From early versions
117122

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:
123124

124-
Example:
125125
```javascript
126126
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 in output.contracts)
127+
var input = 'contract x { function g() {} }'
128+
// Setting 1 as second paramater activates the optimiser
129+
var output = solc.compile(input, 1)
130+
for (var contractName in output.contracts) {
131+
// code and ABI that are needed by web3
133132
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
133+
console.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface))
134+
}
134135
```
135136

136137
### Using with Electron

0 commit comments

Comments
 (0)