I'm trying to write something like ICO projects do and I got this problem when it comes to withdraw the ether in the contract's balance to my wallet.

function withdrawal () public payable 
    address bank = 0x...... ;
    address myAddress = this;
    require(myAddress.balance >= 1000000000000000);


When the contract has ether in it, nothing happens. It doesn't even try to send it. So I'm wondering what I am doing wrong, or if there is a better way to do it. Thanks in advance guys, appreciate every answer.

1 Answer 1


I suspec that your contract doesn't actually have a valid balance and/or require(myAddress.balance >= 1000000000000000); is your problem. You should change this to require(address(this).balance >= 1000000000000000) That being said this is incredibly inefficient code and can be better written as

contract ICO {
    address public bank = ......;

    function withdrawal() public {
        require(address(this).balance >= 1000000000000000);


Also make sure the address declare as bank isn't a contract, and if it is, that it has a payable fallback function, otherwise this will also fail


Due to the way your code written I suspect you are quite new to solidity, and don't yet understand all the gotchas, intricacies, and tricks that come to writting solidity smart contracts. I would recommend trying simpler contracts first, and become better affiliated with the language before attempting to write ICO contracts.




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.