0

I am attempting to withdraw ETH from my smart contract that I have deployed using Solidity in Remix. I have already deposited 0.001 ETH into the smart contract using MetaMask and wish to use the withdraw function I created in Solidity to withdraw that 0.001 ETH into my Ether Wallet. However, whenever I click on the withdraw button (and specify that I wish to withdraw 0.001 ETH) in remix, the block explorer shows that I did not withdraw anything. Any guesses why?

Please let me know if you need additional details.

enter image description here enter image description here enter image description here

2
  • Please, provide contract source code as text. It makes testing much easier.
    – Ismael
    Mar 3, 2023 at 14:32
  • Were you able to transfer your eth to Metamask? Because I also have Eth in a smartcontract but the withdrawal option doesnt work properly. Could you send me the code you used?
    – Xavier
    Apr 12, 2023 at 11:27

1 Answer 1

1

The withdraw_amount should be in wei. Because you have put withdraw amount 1 and you are dividing it by 1000 in uint256 division 1/1000 is 0.

You have to pass withdraw_amountt in wei like

1000000000000000000 = 1 ether
1000000000000000000/1000 = 10000000000000000 = 0.001 ether
4
  • Hi, thanks for your answer. The wei computation is indeed correct. I tried your method and the withdrawal amount goes to 0.001 ether, but on (goerli.etherscan.io/tx/…) it shows a contract value of zero, which does not make sense. Any ideas? My wallet balance also shows no funds being withdrawn successfully
    – KaiSqDist
    Feb 25, 2023 at 15:32
  • The ETH withdrawn from any contract is in the record under internal transaction in etherscan. You can check the incoming ETH amounts in your wallet in internal transaction tab. goerli.etherscan.io/address/…
    – Safi
    Feb 26, 2023 at 5:51
  • Thank you so much! I wish I could upvote your comment because I have been cracking my head for so long over this. How long does it usually take for the ETH to come into your account?
    – KaiSqDist
    Feb 26, 2023 at 10:54
  • As long as the transaction is complete
    – Safi
    Feb 26, 2023 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.