Skip to content

Commit a56de7c

Browse files
committed
Use consistent style (matching standard)
1 parent fa76132 commit a56de7c

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ used in combination with an Ethereum client via the `eth.compile.solidity()` RPC
3434
It can also be included and used in other projects:
3535

3636
```javascript
37-
var solc = require('solc');
38-
var input = 'contract x { function g() {} }';
39-
var output = solc.compile(input, 1); // 1 activates the optimiser
37+
var solc = require('solc')
38+
var input = 'contract x { function g() {} }'
39+
// Setting 1 as second paramateractivates the optimiser
40+
var output = solc.compile(input, 1)
4041
for (var contractName in output.contracts) {
4142
// code and ABI that are needed by web3
42-
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
43-
console.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface));
43+
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
44+
console.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface))
4445
}
4546
```
4647

@@ -49,14 +50,14 @@ for (var contractName in output.contracts) {
4950
Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:
5051

5152
```javascript
52-
var solc = require('solc');
53+
var solc = require('solc')
5354
var input = {
5455
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',
5556
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
56-
};
57-
var output = solc.compile({sources: input}, 1);
57+
}
58+
var output = solc.compile({ sources: input }, 1)
5859
for (var contractName in output.contracts)
59-
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
60+
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
6061
```
6162

6263
Note that all input files that are imported have to be supplied, the compiler will not load any additional files on its own.
@@ -66,19 +67,19 @@ Note that all input files that are imported have to be supplied, the compiler wi
6667
Starting from version 0.2.1, a callback is supported to resolve missing imports as follows:
6768

6869
```javascript
69-
var solc = require('solc');
70+
var solc = require('solc')
7071
var input = {
7172
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
72-
};
73-
function findImports(path) {
73+
}
74+
function findImports (path) {
7475
if (path === 'lib.sol')
7576
return { contents: 'library L { function f() returns (uint) { return 7; } }' }
7677
else
7778
return { error: 'File not found' }
7879
}
79-
var output = solc.compile({sources: input}, 1, findImports);
80+
var output = solc.compile({ sources: input }, 1, findImports)
8081
for (var contractName in output.contracts)
81-
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
82+
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
8283
```
8384

8485
The `compile()` method always returns an object, which can contain `errors`, `sources` and `contracts` fields. `errors` is a list of error mesages.
@@ -99,21 +100,21 @@ new BrowserWindow({
99100
webPreferences: {
100101
nodeIntegration: false
101102
}
102-
});
103+
})
103104
```
104105

105106
### Using a Legacy Version
106107

107108
In order to compile contracts using a specific version of Solidity, the `solc.useVersion` method is available. This returns a new `solc` object that uses a version of the compiler specified. **Note**: version strings must match the version substring of the files available in `/bin/soljson-*.js`. See below for an example.
108109

109110
```javascript
110-
var solc = require('solc');
111+
var solc = require('solc')
111112
// by default the latest version is used
112113
// ie: solc.useVersion('latest')
113114

114115
// getting a legacy version
115-
var solcV011 = solc.useVersion('v0.1.1-2015-08-04-6ff4cd6');
116-
var output = solcV011.compile('contract t { function g() {} }', 1);
116+
var solcV011 = solc.useVersion('v0.1.1-2015-08-04-6ff4cd6')
117+
var output = solcV011.compile('contract t { function g() {} }', 1)
117118
```
118119

119120
If the version is not available locally, you can use `solc.loadRemoteVersion(version, callback)` to load it directly from GitHub.
@@ -126,15 +127,15 @@ You can also load the "binary" manually and use `setupMethods` to create the fam
126127
By default, the npm version is only created for releases. This prevents people from deploying contracts with non-release versions because they are less stable and harder to verify. If you would like to use the latest development snapshot (at your own risk!), you may use the following example code.
127128

128129
```javascript
129-
var solc = require('solc');
130+
var solc = require('solc')
130131

131132
// getting the development snapshot
132-
solc.loadRemoteVersion('latest', function(err, solcSnapshot) {
133+
solc.loadRemoteVersion('latest', function (err, solcSnapshot) {
133134
if (err) {
134135
// An error was encountered, display and quit
135136
}
136-
var output = solcSnapshot.compile("contract t { function g() {} }", 1);
137-
});
137+
var output = solcSnapshot.compile("contract t { function g() {} }", 1)
138+
})
138139
```
139140

140141
### Linking Bytecode
@@ -144,7 +145,7 @@ When using libraries, the resulting bytecode will contain placeholders for the r
144145
The `linkBytecode` method provides a simple helper for linking:
145146

146147
```javascript
147-
bytecode = solc.linkBytecode(bytecode, { 'MyLibrary': '0x123456...' });
148+
bytecode = solc.linkBytecode(bytecode, { 'MyLibrary': '0x123456...' })
148149
```
149150

150151
Note: in future versions of Solidity a more sophisticated linker architecture will be introduced. Once that changes, this method will still be usable for output created by old versions of Solidity.
@@ -155,9 +156,9 @@ The ABI generated by Solidity versions can differ slightly, due to new features
155156

156157
It can be used as:
157158
```javascript
158-
var abi = require('solc/abi');
159+
var abi = require('solc/abi')
159160

160-
var inputABI = [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"}];
161+
var inputABI = [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"}]
161162
var outputABI = abi.update('0.3.6', inputABI)
162163
// Output contains: [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":true,"type":"function"},{"type":"fallback","payable":true}]
163164

0 commit comments

Comments
 (0)