Cover photo

When a Contract Sends Ether to Itself While Dying

Fabian Owuor

Fabian Owuor

Starring: StrangeSelfDestruct.sol
Genre: Horror-Comedy
Rating: 🤯 (For mind-bending logic)

Prologue: Solidity's Final Goodbye

In the sprawling realm of the Ethereum Virtual Machine, there's a little-known magic spell called selfdestruct.

When cast, it:

  • Instantly deletes the contract’s code from the blockchain (like Ctrl+Alt+Del, but in CAPS and permanent),

  • Transfers all of the contract's ether to a chosen address.

Now usually, you'd use this spell to:

  • Clean up after a failed project,

  • Send leftover funds back to a trusted wallet,

  • Or make a rage quit statement against "the machine".

But what if the chosen address is... itself?

Meet the Star: StrangeSelfDestruct.sol

solidityCopyEditpragma solidity ^0.8.0;

contract StrangeSelfDestruct {
    constructor() payable {}

    function boom() external {
        selfdestruct(payable(address(this)));
    }
}

This contract bravely says:

"I’m going to die... and leave all my money to... me. How selfish"

It's like throwing yourself a retirement party, then setting your house on fire with your inheritance inside it — and expecting Future You to still enjoy it.

What Actually Happens?

When boom() is called:

  1. The contract is deleted from the blockchain — its code goes poof.

  2. Any remaining ether is sent to address(this) — which was the contract.

  3. But address(this) no longer has any code, because... it's also "dead".

  4. The ether still arrives at that address, but:

    • It just sits there.

    • No one can touch it.

    • No fallback. No function. No recovery.

    • Just a zombie address with money.

Congratulations! You’ve just created a haunted piggy bank. I may be dead, but I still hold value.

Is It Really Useless?

Not entirely! This self-yeeting behavior can be used strategically (or maliciously) to:

  • Burn Ether: Ether ends up in an address with no contract or private key. It's like throwing ETH into a volcano.

  • Signal Destruction: You could track when the contract killed itself via emitted events and store Ether as a "tombstone marker."

  • Create Confusion: (A+ for chaos engineers and prank-loving auditors.)

So yes — it’s basically performance art on the blockchain.

What If I Try to Interact with It After?

Let’s say you’re a curious dev, trying to call the dead contract again:

jsCopyEditawait contract.boom()

The chain replies:

“There’s no code at this address, buddy. Please, go find something useful to do”

Try sending ETH?
Sure, it can hold ETH — but can't do anything with it. Not even return a “thanks.”

It's like leaving a voicemail for someone who’s already a ghost. You need help.

TL;DR: The Crypto Equivalent of Talking to Yourself

StrangeSelfDestruct is:

  • A great way to lock funds forever in a void.

  • A tragic comedy of existentialism in 10 lines of code.

  • Proof that even smart contracts can have an identity crisis.

Bonus: Want to Troll an Auditor?

Deploy this contract with 5 ETH.

Then run boom().

Now wait for the auditor to go:

“Uhh... Where’d the ETH go?”

“Wait, did... it send the money... to itself while dying?”

nervous laughter

Moral of the Story?

Just because you can do something in Solidity, doesn’t mean you should.
Unless, of course, you're trying to make a philosophical point about the futility of wealth.

In that case — boom, boom and more boom.

When a Contract Sends Ether to Itself While Dying