Search code examples
blockchainethereumsoliditysmartcontracts

Error sending value to Ethereum smart contract


I have geth 1.5.2 and work on testnet with Mist-linux64-0-8-7. I stuck at a simple issue when I try to send some ether (value) to my contract by calling any function. For example, even this dummy function does not work with non-zero value but works normally with zero value:

function t() returns (uint){
    return 1;
}

What is surprising here that I can see a warning in Mist with the message "It seems this transaction will fail. If you submit it, it may consume all the gas you send." This does not depend on the gas amount that I provide. Even if I put 500,000 of gas the transaction seem not to complete.

You can see its result here: https://testnet.etherscan.io/tx/0x3206118530079d1b416dc649c6f0a89283f9457e9189f259b3429cf0c6a998d0

There is a message

Warning! Error encountered during contract execution [Bad jump destination]

I tried to run different functions in different contracts. I was even using sendTransaction functionality to do the same from geth console directly but I still can't make it work. I didn't find if anybody had similar problem. Please help me if you have any idea.


Solution

  • From Solidity 0.4 onwards:

    Functions that want to receive Ether have to specify the new payable modifier (otherwise they throw).

    A throw consumes all gas, so use function t() payable returns (uint).