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,050 points
45 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 16,450 points

Related Questions In Blockchain

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,040 points
164 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
88 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,000 points
44 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
• 16,450 points
223 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
• 16,450 points
167 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.