Error in sending value to an Ethereum Smart Contract.

0 votes

I have geth 1.5.2 and working on testnet with Mist-linux64-0-8-7.  When I try to send some ethers (value) to my contract by calling any function, I get stuck. For example, this dummy function does not work with non-zero value but works normally with zero value:

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

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.

The message I encounter is -

Warning! Error encountered during contract execution!

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.

Jul 23, 2018 in Blockchain by sabby
• 4,350 points
49 views

1 answer to this question.

0 votes

It is stated in Solidity 4.0 documentation that: "Functions that want to receive ethers have to specify the new payable modifier (otherwise the throw)." A throw consumes all gas, so use function t() payable returns (uint).

answered Jul 23, 2018 by Perry
• 17,010 points

Related Questions In Blockchain

0 votes
1 answer

How to get notified when an event triggers on ethereum smart contract?

Here's a simple example for web3js 1.0.0.beta*: function handler ...READ MORE

answered Jun 8, 2018 in Blockchain by ariaholic
• 7,340 points
340 views
0 votes
1 answer

Error when trying to deploy Ethereum smart contract using web3j

Create a new credential based on the Credentials.create ...READ MORE

answered Oct 3, 2018 in Blockchain by slayer
• 29,050 points
185 views
0 votes
1 answer

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,010 points
44 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
126 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,290 points
66 views
0 votes
1 answer
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,010 points
316 views