src/quorum/quorum.js
/**
     * Deploy the chaincode specified in the network configuration file to all peers.
     * @return {Promise} The return promise.
     */
Deploy the chaincode specified in the network configuration file to all peers.
@return {Promise} The return promise.
Deploy the chaincode specified in the network configuration file to all peers . @return { Promise } The return promise .
installSmartContract(contracts_config) {
        let bc = this;
        let contract_config = contracts_config[0];
        let contract_name = contract_config.name;
        let contract_path = commUtils.resolvePath(contract_config.path);
        const nodeUrl = this.nodes_info[0].url;
        const web3 = new Web3(new Web3.providers.HttpProvider(nodeUrl));
        const input = fs.readFileSync(contract_path);
        const output = solc.compile(input.toString(), 1); 
        const bytecode = '0x' + output.contracts[':' + contract_name].bytecode;
        const abi = JSON.parse(output.contracts[':' + contract_name].interface);
        return web3.eth.getAccounts()
            .then((accounts)=>{
                let from_acc = accounts[0];
                let contractInstance = new web3.eth.Contract(abi);
                return  new Promise((resolve, reject) => {
                    contractInstance.deploy({
                        data: bytecode
                    }).send({
                        from: from_acc,
                        gas: 15000000,
                        privateFor: bc.private? bc.privateFor:undefined
                    }).once('receipt', function(receipt){
                        let addr = receipt.contractAddress.toString();
                        console.log("Receive contract addr in txn receipt ", addr);
                        return resolve([addr, abi]);
                    });
                });
        });
    }
installSmartContract ( contracts_config ) { let bc = this ; let contract_config = contracts_config [ 0 ] ; let contract_name = contract_config . name ; let contract_path = commUtils . resolvePath ( contract_config . path ) ; const nodeUrl = this . nodes_info [ 0 ] . url ; const web3 = new Web3 ( new Web3 . providers . HttpProvider ( nodeUrl ) ) ; const input = fs . readFileSync ( contract_path ) ; const output = solc . compile ( input . toString ( ) , 1 ) ; const bytecode = '0x' + output . contracts [ ':' + contract_name ] . bytecode ; const abi = JSON . parse ( output . contracts [ ':' + contract_name ] . interface ) ; return web3 . eth . getAccounts ( ) . then ( ( accounts ) => { let from_acc = accounts [ 0 ] ; let contractInstance = new web3 . eth . Contract ( abi ) ; return new Promise ( ( resolve , reject ) => { contractInstance . deploy ( { data : bytecode } ) . send ( { from : from_acc , gas : 15000000 , privateFor : bc . private ? bc . privateFor : undefined } ) . once ( 'receipt' , function ( receipt ) { let addr = receipt . contractAddress . toString ( ) ; console . log ( "Receive contract addr in txn receipt " , addr ) ; return resolve ( [ addr , abi ] ) ; } ) ; } ) ; } ) ; }
Deploy the chaincode specified in the network configuration file to all peers.
Deploy the chaincode specified in the network configuration file to all peers .
// Use the first node // compute the abi, bytecode using solc. // convert buffer to string and compile // console.log("Compiled Output: ", output); // console.log("Generated ABI: ", abi_str);