From 12bdb5f5509c205a7a868e02964ed25d10f4b000 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 14 Jan 2015 12:01:11 +0100 Subject: providers documentation --- lib/contract.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lib/contract.js') diff --git a/lib/contract.js b/lib/contract.js index eb7fbf018..d38746f01 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -27,9 +27,29 @@ if (process.env.NODE_ENV !== 'build') { var abi = require('./abi'); -// method signature length in bytes +/// method signature length in bytes var ETH_METHOD_SIGNATURE_LENGTH = 4; +/** + * This method should be called when we want to call / transact some solidity method from javascript + * it returns an object which has same methods available as solidity contract description + * usage example: + * + * var abi = [{ + * name: 'myMethod', + * inputs: [{ name: 'a', type: 'string' }], + * outputs: [{name 'd', type: 'string' }] + * }]; // contract abi + * + * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object + * + * myContract.myMethod('this is test string param for call').cal(); // myMethod call + * myContract.myMethod('this is test string param for transact').transact() // myMethod transact + * + * @param address - address of the contract, which should be called + * @param desc - abi json description of the contract, which is being created + * @returns contract object + */ var contract = function (address, desc) { var inputParser = abi.inputParser(desc); var outputParser = abi.outputParser(desc); @@ -70,3 +90,4 @@ var contract = function (address, desc) { }; module.exports = contract; + -- cgit v1.2.3 From 70bf1a57113381d33bb26f0d8839f1dacc6fa303 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 15 Jan 2015 11:39:02 +0100 Subject: fixed typos --- lib/contract.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/contract.js') diff --git a/lib/contract.js b/lib/contract.js index d38746f01..52ce08705 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -38,12 +38,12 @@ var ETH_METHOD_SIGNATURE_LENGTH = 4; * var abi = [{ * name: 'myMethod', * inputs: [{ name: 'a', type: 'string' }], - * outputs: [{name 'd', type: 'string' }] + * outputs: [{name: 'd', type: 'string' }] * }]; // contract abi * * var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object * - * myContract.myMethod('this is test string param for call').cal(); // myMethod call + * myContract.myMethod('this is test string param for call').call(); // myMethod call * myContract.myMethod('this is test string param for transact').transact() // myMethod transact * * @param address - address of the contract, which should be called -- cgit v1.2.3