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,390 points

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,100 points

Related Questions In Blockchain

0 votes
2 answers

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

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

answered May 2, 2020 in Blockchain by aqowcmbevs
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,350 points
0 votes
1 answer

How to swap an Ethereum ERC-20 and Neo NEP5 token with a smart contract?

Each blockchain is its own separated administration. ...READ MORE

answered Apr 12, 2022 in Blockchain by Soham
• 9,700 points
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
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
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
• 69,230 points
+1 vote
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,100 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP