]> git.ardis.lu - minimal-eth-burner/commitdiff
Initial commit
authorArdis Lu <ardisglu@gmail.com>
Mon, 14 Aug 2023 05:33:14 +0000 (22:33 -0700)
committerArdis Lu <ardisglu@gmail.com>
Mon, 14 Aug 2023 05:33:14 +0000 (22:33 -0700)
README.md [new file with mode: 0644]
burner.evm [new file with mode: 0644]
deployer.evm [new file with mode: 0644]

diff --git a/README.md b/README.md
new file mode 100644 (file)
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 (file)
index 0000000..4901871
--- /dev/null
@@ -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 (file)
index 0000000..3f9b24d
--- /dev/null
@@ -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
This page took 0.046058 seconds and 4 git commands to generate.