I have setup my private blockchain for testing. And created and deployed following contract:
pragma solidity 0.4.11;
contract Multiply7 {
event Print(uint);
function multiply(uint input) returns (uint) {
Print(input * 7);
return input * 7;
}
}
Generated abi
and code
using solc
:
6060604052341561000c57fe5b5b60df8061001b6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa114603a575bfe5b3415604157fe5b60556004808035906020019091905050606b565b6040518082815260200191505060405180910390f35b60007f24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da600783026040518082815260200191505060405180910390a16007820290505b9190505600a165627a7a7230582089c25c3ddf32ed3ef55436bff071176b9b807c9cac456721766027c17261657e0029
ABI here:
[{"constant":false,"inputs":[{"name":"input","type":"uint256"}],"name":"multiply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"","type":"uint256"}],"name":"Print","type":"event"}]
Deployed contract and got transaction receipt:
eth.sendTransaction({from: eth.accounts[0], data: code})
contractAddress = eth.getTransactionReceipt('0x2d1483f05c0420284ccc4f1ad4003466cc6b51e119c1009d6edfd966a9ec399f').contractAddress
//0x84a56a919232516d2f928ed1b66423e974de4c8b
Now I am accessing this contract:
myContract = eth.contract(abi)
contract = myContract.at('0x84a56a919232516d2f928ed1b66423e974de4c8b')
contract.multiple.call(6) // always returns 0
When I paste code
from example from here everything works just fine.
I am not understanding what is the problem with my approach. My solc code and abi are correct? Any help would be appreciated. Thank you.
multiply(...)
function with aconstant
modifier, your call should work. Otherwise you have to send a transaction to execute yourmultiply(...)
function. – The Officious BokkyPooBah May 23 '17 at 6:04