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:


ABI here:


Deployed contract and got transaction receipt:

eth.sendTransaction({from: eth.accounts[0], data: code})
contractAddress = eth.getTransactionReceipt('0x2d1483f05c0420284ccc4f1ad4003466cc6b51e119c1009d6edfd966a9ec399f').contractAddress

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.

  • If you mark your multiply(...) function with a constant modifier, your call should work. Otherwise you have to send a transaction to execute your multiply(...) function. May 23 '17 at 6:04

Try increasing gaslimit:

eth.sendTransaction({from: eth.accounts[0], data: code, gas: 100000})


As default gas is 90000 which may be less for transaction with data. Check eth.getCode('0x84a56a919232516d2f928ed1b66423e974de4c8b') before you access the contract. If it doesn't return your contract code, contract wasn't deployed properly.

  • What this has to do with gas limit? May 22 '17 at 12:05
  • @PrashantPrabhakarSingh Because default gas in sendTransaction is 90000, which is enough for transaction with no data but fails for contract creation (which may take more than default gas) May 22 '17 at 17:12
  • 1
    hmm.. that may be the case if the contract is deployed without any data. You can edit the answer explaining others the logic behind your statement. Upvoted. :) May 23 '17 at 3:50
  • @PrashantPrabhakarSingh Added explanation. Thanks. May 23 '17 at 4:07

I think you should call contract.multiply.call(6) not contract.multiple

  • I think that was question typo. contract.multiply.call(6) doesn't work as he says. May 22 '17 at 5:43

The problem here is upon creation of your contract you do not send enough gas. By default it is 90000 ( for Geth ) or the results given after creating it are

Transaction cost: 112321 gas. Execution cost: 44689 gas.

As you can see more gas are required to create the contract than the default value.

You have to send more gas during your transaction in order to make the creation successful by adding the following parameter :

eth.sendTransaction({from: eth.accounts[0], data: code, gas: 200000})

And speaking about gas you should mark your method constant like this

function multiply (uint input) constant returns (uint)

Constant indicates that your function is not supposed to modify the states, and no gas will be used because it allows to the function to be executed locally/off blockchain in your node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.