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
95 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,090 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,240 points
429 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,810 points
186 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
• 68,160 points
118 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,090 points
495 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,090 points
239 views