diff options
Diffstat (limited to 'lib/contract.js')
-rw-r--r-- | lib/contract.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/contract.js b/lib/contract.js index b10339003..4cb202255 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -27,6 +27,9 @@ if (process.env.NODE_ENV !== 'build') { var abi = require('./abi'); +// method signature length in bytes +var ETH_METHOD_SIGNATURE_LENGTH = 4; + var contract = function (address, desc) { var inputParser = abi.inputParser(desc); var outputParser = abi.outputParser(desc); @@ -46,8 +49,10 @@ var contract = function (address, desc) { call: function (extra) { extra = extra || {}; extra.to = address; - extra.data = parsed; - return web3.eth.call(extra).then(onSuccess); + return abi.methodSignature(desc, method.name).then(function (signature) { + extra.data = signature.slice(0, 2 + ETH_METHOD_SIGNATURE_LENGTH * 2) + parsed; + return web3.eth.call(extra).then(onSuccess); + }); }, transact: function (extra) { extra = extra || {}; |