From 0b2bba6967838d20a37c9e14e67ba50e48b59fd4 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 13 Aug 2023 22:33:14 -0700 Subject: [PATCH] Initial commit --- README.md | 29 +++++++++++++++++++++++++++++ burner.evm | 11 +++++++++++ deployer.evm | 25 +++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 README.md create mode 100644 burner.evm create mode 100644 deployer.evm diff --git a/README.md b/README.md new file mode 100644 index 0000000..4505847 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# minimal-eth-burner + +In Ethereum, it's common to send ETH to a "burner address" like [`0x000000000000000000000000000000000000dead`](https://etherscan.io/address/0x000000000000000000000000000000000000dead) to effectively "destroy" ETH. + +However, this ETH is theoretically recoverable if the private key for this public address is ever discovered. The only way to actually destroy ETH is by sending ETH to a smart contract which calls `SELFDESTRUCT` and sends its ETH to itself. + +This repository contains the minimal amount of code to create a new smart contract that immediately calls `SELFDESTRUCT` and sends its ETH to itself. All ETH sent to the smart contract creation transaction will be irreversibly destroyed. + +## Usage + +See example JavaScript below. Copy this code into the DevTools console in any web browser where you have a wallet (e.g., MetaMask) installed. + +**WARNING: all ETH sent in this transaction will be irreversibly destroyed.** + +```javascript +const addr = (await ethereum.request({ method: 'eth_requestAccounts' }))[0]; // Your current wallet address +const deployer = '0x696130ff5f526002601ef35f52600a601634f05f5f5f5f5f855af1'; // deployer.evm, compiled +const burn = '100000000000000000'; // Amount of ETH to burn (in wei) + +// Irreversibly destroys all ETH sent +await ethereum.request({ + method: 'eth_sendTransaction', + params: [{ + from: addr, + data: deployer, + value: `0x${BigInt(burn).toString(16)}` + }] +}); +``` diff --git a/burner.evm b/burner.evm new file mode 100644 index 0000000..4901871 --- /dev/null +++ b/burner.evm @@ -0,0 +1,11 @@ +;; This is creation bytecode which will return 0x30ff when run +PUSH2 0x30ff ;; value +PUSH0 ;; offset +MSTORE + +PUSH1 2 ;; size +PUSH1 30 ;; offset +RETURN + +;; The above code, compiled: +;; 0x6130ff5f526002601ef3 diff --git a/deployer.evm b/deployer.evm new file mode 100644 index 0000000..3f9b24d --- /dev/null +++ b/deployer.evm @@ -0,0 +1,25 @@ +;; This code will: +;; 1. Create a new smart contract using burner.evm +;; 2. Call the new smart contract + +;; burner.evm, compiled +PUSH10 0x6130ff5f526002601ef3 ;; value +PUSH0 ;; offset +MSTORE + +PUSH1 10 ;; size +PUSH1 22 ;; offset +CALLVALUE ;; value +CREATE + +PUSH0 ;; retSize +PUSH0 ;; retOffset +PUSH0 ;; argsSize +PUSH0 ;; argsOffset +PUSH0 ;; value +DUP6 ;; address +GAS ;; gas +CALL + +;; This smart contract, compiled: +;; 0x696130ff5f526002601ef35f52600a601634f05f5f5f5f5f855af1 -- 2.47.3