Created
July 14, 2017 10:03
-
-
Save inovizz/1fdc2af0182584b90008e0cf2895554c 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
const fs = require("fs"); | |
const solc = require('solc') | |
let Web3 = require('web3'); | |
let web3 = new Web3(); | |
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); | |
var input = { | |
'strings.sol': fs.readFileSync('strings.sol', 'utf8'), | |
'StringLib.sol': fs.readFileSync('StringLib.sol', 'utf8'), | |
'Killable.sol': fs.readFileSync('Killable.sol', 'utf8'), | |
'Ownable.sol': fs.readFileSync('Ownable.sol', 'utf8'), | |
'LMS.sol': fs.readFileSync('LMS.sol', 'utf8') | |
}; | |
let compiledContract = solc.compile({sources: input}, 1); | |
let abi = compiledContract.contracts['LMS.sol:LMS'].interface; | |
let bytecode = '0x'+compiledContract.contracts['LMS.sol:LMS'].bytecode; | |
let gasEstimate = web3.eth.estimateGas({data: bytecode}); | |
let LMS = web3.eth.contract(JSON.parse(abi)); | |
var lms = LMS.new("sanchit", "[email protected]", { | |
from:web3.eth.coinbase, | |
data:bytecode, | |
gas: gasEstimate | |
}, function(err, myContract){ | |
if(!err) { | |
if(!myContract.address) { | |
console.log(myContract.transactionHash) | |
} else { | |
console.log(myContract.address) | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment