Tidy nodejs/npm usage

pull/1/head
d11e9 9 years ago
parent cf97d6dd55
commit 5f93ea16e8
  1. 11
      README.md
  2. 10
      index.js
  3. 4
      package.json

@ -3,13 +3,16 @@
Browser solidity is a browser based solidity compiler. To use either visit https://chriseth.github.io/browser-solidity or clone/download this repo and open `index.html` in your browser.
#Solidity compiler
#Nodejs usage
To use the solidity compiler via nodejs you can do the following:
To use the solidity compiler via nodejs you can install it via npm
npm install --save solc
And then use it like so:
var solc = require('solc');
var compileJSON = solc.cwrap("compileJSON", "string", ["string", "number"]);
var input = "contract x { function g() {} }";
var output = JSON.parse(compileJSON(input, 1)); // 1 activates the optimiser
var output = solc.compile(input, 1); // 1 activates the optimiser
for (var contractName in output.contracts)
console.log(contractName + ': ' + output.contracts[contractName].bytecode);

@ -0,0 +1,10 @@
var soljson = require('./bin/soljson-latest.js');
compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]);
module.exports = {
compile: function(input, optimise){
return JSON.parse( compileJSON(input, optimise) );
}
}

@ -2,9 +2,9 @@
"name": "solc",
"version": "0.1.3",
"description": "Solidity compiler",
"main": "soljson-latest.js",
"main": "index.js",
"bin": {
"solc": "soljson-latest.js"
"solc": "bin/soljson-latest.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"

Loading…
Cancel
Save