From a20e03135b4fd681a25544acd78865c9388faaed Mon Sep 17 00:00:00 2001 From: cseberino Date: Mon, 30 May 2016 15:27:02 -0500 Subject: Update contracts.rst --- docs/contracts.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/contracts.rst b/docs/contracts.rst index 81c5d353..372d24da 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -23,7 +23,10 @@ name as the contract) is executed once. From ``web3.js``, i.e. the JavaScript API, this is done as follows:: + var source = <> + // The json abi array generated by the compiler + var abiArray = [ { "inputs":[ @@ -41,12 +44,13 @@ API, this is done as follows:: } ]; - var MyContract = web3.eth.contract(abiArray); + var MyContract_ = web3.eth.contract(source); + MyContract = web3.eth.contract(MyContract_.CONTRACT_NAME.info.abiDefinition); // deploy new contract var contractInstance = MyContract.new( 10, 11, - {from: myAccount, gas: 1000000} + {from: myAccount, gas: 1000000, data = MyContract.CONTRACT_NAME.code} ); .. index:: constructor;arguments -- cgit v1.2.3 From d5e536a4fb2a87efe8de3df9bda487ca2459e24c Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 1 Aug 2016 12:14:17 +0200 Subject: Made snippet work as is. --- docs/contracts.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/contracts.rst b/docs/contracts.rst index 372d24da..3d592ecf 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -23,10 +23,10 @@ name as the contract) is executed once. From ``web3.js``, i.e. the JavaScript API, this is done as follows:: - var source = <> + // Need to specify some source including contract name for the data param below + var source = "contract CONTRACT_NAME { function CONTRACT_NAME(unit a, uint b) {} }"; // The json abi array generated by the compiler - var abiArray = [ { "inputs":[ @@ -50,7 +50,7 @@ API, this is done as follows:: var contractInstance = MyContract.new( 10, 11, - {from: myAccount, gas: 1000000, data = MyContract.CONTRACT_NAME.code} + {from: myAccount, gas: 1000000} ); .. index:: constructor;arguments -- cgit v1.2.3