Created
February 5, 2016 13:28
-
-
Save agatsoh/9e1241b38e0f40af0a76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var solc = require('solc'); | |
var fs = require('fs'); | |
var Web3 = require('web3'); | |
const assert = require('assert'); | |
var web3; | |
if(typeof web3 !== 'undefined') | |
web3 = new Web3(web3.currentProvider); | |
else | |
// set the provider you want from Web3.providers | |
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:4000/")); | |
var input = { "IOU.sol":fs.readFileSync('contracts/IOU.sol','utf8'), | |
"Fund.sol":fs.readFileSync('contracts/Fund.sol','utf8'), | |
"RootRegistry.sol":fs.readFileSync('contracts/RootRegistry.sol','utf8'), | |
"Gateway.sol":fs.readFileSync('contracts/Gateway.sol','utf8') | |
}; | |
var output = solc.compile({sources:input},1); | |
for (var contractName in output.contracts){ | |
deployContract(contractName,output.contracts[contractName]); | |
} | |
function deployContract(contractName,contractJSONObject) | |
{ | |
var contractObj = web3.eth.contract(contractJSONObject.interface); | |
//console.log(contractObj.abi); | |
var contractNew = contractObj.new( | |
{ | |
from: web3.eth.accounts[0], | |
data:contractJSONObject.bytecode, | |
gas:3000000 | |
}, function(e, contract){ | |
console.log(contract.transactionHash); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var solc = require('solc');
var fs = require('fs');
var Web3 = require('web3');
const assert = require('assert');
var web3;
if(typeof web3 !== 'undefined')
web3 = new Web3(web3.currentProvider);
else
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:4000/"));
var input = { "IOU.sol":fs.readFileSync('contracts/IOU.sol','utf8'),
"Fund.sol":fs.readFileSync('contracts/Fund.sol','utf8'),
"RootRegistry.sol":fs.readFileSync('contracts/RootRegistry.sol','utf8'),
"Gateway.sol":fs.readFileSync('contracts/Gateway.sol','utf8')
};
var output = solc.compile({sources:input},1);
//console.log(output);
for (var contractName in output.contracts){
}
function deployContract(contractName,contractJSONObject)
{
//console.log(typeof contractJSONObject.interface);
//console.log(typeof JSON.parse(contractJSONObject.interface));
var contractObj = web3.eth.contract(JSON.parse(contractJSONObject.interface));
//console.log(contractObj.abi);
}