2

I have just started using ethereum and trying to create a greeter contract.

I followed the instructions on the below link:- https://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial

I have used online solidity compiler and using windows version of go-ethereum created a 2 node private setup.

I am able to create the contract and its mined as well.But when I try to kill the contract using the below command:- greeter.kill.sendTransaction({from:eth.accounts[0]})

It doesn't work out whether I try the above command from node1 or node2.

I am expecting an error from Node2(as I created the contract from node1) and success from node1 but nothing happens on both.

Can someone please explain this behaviour?

  • Is your account unlocked when you send the transaction? What kind of response are you getting back when you invoke the kill function on the contract? – dbryson Jun 10 '16 at 13:22
1

If you have a transaction hash "0x....." you can trace what is wrong with your transaction: debug.traceTransaction("0x.....").

Frequently the problem is not enough gas, in that case try adding a gas parameter to your transaction. greeter.kill.sendTransaction({from:eth.accounts[0], gas:3000000})

You can also estimate the gas consumption with: greeter.kill.estimateGas({from:eth.accounts[0]})

  • Thanks, by specifying the gas, it works from node1 but from node2, if I try the same operation with gas param specified, still I don't see any error response. Also do I always need to specify the gas parameter as my account had enough gas but still the tranasaction was not happening? – Aman C Jun 13 '16 at 5:21
  • @AmanC IMO specifying gas is a good idea. It is the max amount you are going to pay for, but you will only be charged by the final consumption. But since in case of an error you will pay the max it is best to have a good estimation. I usually add a 10% to estimateGas just in case. – Ismael Jun 13 '16 at 17:07
  • @AmanC Is eth.accounts[0] the same in both nodes? Does sendTransaction returns an txhash? Did you try debug.traceTransaction when the failure occurs? – Ismael Jun 13 '16 at 17:11
  • No eth.accounts[0] are different for both nodes. Yes sendTransaction returns a hash, and when I do a debug.traceTransaction, I don't see any error. From node2, the last op code is STOP whereas from node1 the last op code is SUICIDE(as expected). – Aman C Jun 14 '16 at 4:45
  • @AmanC In that contract only the owner can kill it. If you have deployed it from node1, only node1 you can kill it. The relevant code is function kill() { if (msg.sender == owner) suicide(owner); }. – Ismael Jun 14 '16 at 18:02

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.