-
Notifications
You must be signed in to change notification settings - Fork 5
/
contractfirminit.js
24 lines (22 loc) · 1013 Bytes
/
contractfirminit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
fs = require('fs');
Web3 = require('web3');
web3 = new Web3( new Web3.providers.HttpProvider("http://localhost:8545/") );
console.log("Connected to Blockchain !!");
code = fs.readFileSync("contractfirm.sol").toString();
solc = require('solc');
console.log("Compiling Contract firm.sol ...");
compiledCode = solc.compile( code );
console.log("Compiled successfully!!");
abi = JSON.parse( compiledCode.contracts[":contractfirm"].interface );
console.log("JSON is : "+ compiledCode.contracts[":contractfirm"].interface);
byteCode = compiledCode.contracts[':contractfirm'].bytecode ;
realEstateContract = web3.eth.contract(abi) ;
console.log("Deploying ...")
deployedContract = realEstateContract.new({data: byteCode , from: web3.eth.accounts[0] , gas: 3000000 },
( e , contract )=>{
if( contract.address )
{
console.log("Deployed successfully...\n\n\nDeployed Address : " + contract.address );
console.log("Use the above deployed address in realEstate.js ...\n\n");
}
});