How do I withdraw the balance from a contract on Ethereum test blockchain

0 votes

I am using Ganache (TestRPC) for my local blockchain with its default test accounts having 100 ETH balance, connected with Metamask.

I am creating a Withdrawal Contract according to the following documentation: http://solidity.readthedocs.io/en/develop/common-patterns.html using 10 ETH.

Contract is being executed successfully, but when I execute the withdraw() that should refund me the 10ETH amount. 

Metamask shows transaction as success.

But the amount never makes it to my test account. Account balance is still 90ETH.

Aug 3, 2018 in Blockchain by sabby
• 4,370 points
2,668 views

1 answer to this question.

0 votes

Your need to improvise your code a bit. You gotta deploy the contract without sending any ether. Then call becomeRichest(), this time sending in the ether. Then use withdraw.

withdraw() uses the pendingWithdrawalsmapping to determine how much the caller is allowed to transfer out of the contract. Only the becomeRichest() method is setting that mapping. The constructor is not.

answered Aug 3, 2018 by Perry
• 17,100 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
0 votes
2 answers

How do I interact with a smart contract on a private network through web3.js

I found a blog that explains how ...READ MORE

answered Aug 20, 2018 in Blockchain by slayer
• 29,370 points
3,954 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
1,928 views
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
1,456 views
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,220 points
1,468 views
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
3,608 views
0 votes
1 answer

How do I develop a supply chain DApp on Blockchain?

Either of the ways is acceptable but ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,100 points
1,501 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP