Starring: StrangeSelfDestruct.sol
Genre: Horror-Comedy
Rating: 🤯 (For mind-bending logic)
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?
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.
When boom()
is called:
The contract is deleted from the blockchain — its code goes poof.
Any remaining ether is sent to address(this)
— which was the contract.
But address(this)
no longer has any code, because... it's also "dead".
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.
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.
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.
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.
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
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.