0

I am very new to Solidity, and playing around with testrpc and truffle.

One of the thing I would like to do is the self-destruct a contract. Because I do wish to be able to remote my contract during development phase, until it is stable.

contract HelloWorld {
    function sayHello() public pure returns (string) {
        return ("Hello World!");
    }

    function kill()  public {
        selfdestruct(address(this));
    }
}

I am manage to call sayHello() and kill() using truffle console. But the self-destruct doesn't seem to do anything. I am still able to call sayHello().

Wish this question is not too newbie.

0
2

You have to pass address which will receive contracts balance in selfdestruct parameter, not the contracts address. And check that you are using sendTransaction() and not call() in you console method call.

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