Categories
Cryptocurrency Ethereum Mastering Development

Destroy smart contract and collect its funds

I’m quite new at smart contracts/ solidity which I’m learning for a postgraduate course.

In one of the assignments, we have to implement a short example of dutch auction (wiki link). Now my question is that in one of methods, specifically finalize(), the owner of contract must destroy it and collect its funds. And here is my code:

    function finalize() public creatorOnly biddingClosedOnly {
      selfdestruct(_creator);
      if(finalPrice > 0) {
        _creator.transfer(finalPrice);
      }
    }

The rest of contract’s methods are running well in Remix but when I call finalize method, the smart contract is not destroyed and still exists so that anyone can call the other functions as before. What am I doing wrong ?

Leave a Reply

Your email address will not be published. Required fields are marked *