PSA: I'm new to Solidity/Truffle and I'm hoping you guys won't be too harsh on me

I'm trying to figure out how call a function that only the smart contract owner can call. The reason why I want to do this, is because I want to be able to self destruct my contract whenever I want. I've seen guides on how to write the function itself, but that's not exactly in question for me. I just want to know how I can call it as the owner of the smart contract.

Any help would be greatly appreciated, thanks.

Edit: what I currently have

function kaboom() public onlyOwner

1 Answer 1


If I understood your question properly, what you need is a function modifier which will work as a check mechanism before letting the rest of the function to executed.

From the solidity documentation:

Modifiers can be used to change the behavior of functions in a declarative way. For example, you can use a modifier to automatically check a condition prior to executing the function.

You can find the example in the following link

  • Sorry for the confusing wording, I'm trying to find out how to call a function in the contract sometime in the future (in this case selfdestruct()). I already have the onlyOwner modifier attached to my function.
    – whoff
    Commented Nov 19, 2020 at 22:34

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.