
Crypto On a Flashdrive
Ethereum (ETH) recently took a dive. As of the time of writing, it is at less than $2k per coin, having in the past hit a high of $4k.
Therefore Ethereum is a very exciting gift. If you give someone $50 cash, it will never be worth $100. However, ETH has this upside. And if it tanks, then it was just a gift anyway so the recipient won’t feel a personal loss.
The most interesting way to give it is on a flashdrive. Thats what I’m going to teach you how to do today.
This will be a totally unencrypted flashdrive. If someone steals this flashdrive, they have full access to the ETH. Some advise against this, saying it is unsafe. But to me this is no different than gifting someone a piece of gold or silver. Keep the flashdrive safe, and the ETH will be safe.
The Goal
We will be creating a folder with 6 files in it.
- Private key
- the key to this whole thing, this is the only thing in the world that can send $ETH out of the wallet.
- Public Key
- README.md
- A file that explains how to send the $ETH.
- Helpful for gifting to non-technical people.
- send_eth.py
- This is the program for getting ETH off the flashdrive.
- show_address.py
- This program is needed to display the Wallet Address relating to the keys.
- address_qr.png
- A QR code for the wallet address so that $ETH can be sent in easily.
- Physically printing this out and giving it alongside the flashdrive is a great way to add some physicality to the present.
The optional 7th is a folder called “receipts” which can store screenshots or records of any transactions.
How To
If you want to, you can do all of these steps in a folder and then copy it into the flashdrive. However, I run all of these commands directly in the flashdrive.
Step 1: Key Gen
Generate the Private Key
openssl ecparam -name secp256k1 -genkey -noout -out private-key.pem
Derive the public key
openssl ec -in private-key.pem -pubout -out public-key.pem
Step 2: Derive the wallet from the Public key
We need just a bit of python to do this. Run the following code:
from eth_keys import keys
from eth_utils import keccak
from cryptography.hazmat.primitives import serialization
# Read the public key from the PEM file
with open("./public-key.pem", "rb") as f:
public_key_pem = f.read()
# Load the public key using the cryptography library
public_key_obj = serialization.load_pem_public_key(public_key_pem)
# Convert the public key to raw bytes (uncompressed, starts with 0x04)
public_key_bytes = public_key_obj.public_bytes(
encoding=serialization.Encoding.X962,
format=serialization.PublicFormat.UncompressedPoint
)
# Strip the first byte (0x04) to match Ethereum's 64-byte format
public_key_bytes = public_key_bytes[1:]
# Create an Ethereum PublicKey object
public_key = keys.PublicKey(public_key_bytes)
# Derive Ethereum address (Keccak-256 hash of the public key, last 20 bytes)
eth_address = public_key.to_checksum_address()
print("Ethereum Address:", eth_address)
When I ran this, I get this:
travisweber ETH % python show_address.py
Ethereum Address: 0xA89F66061a9B7ce136A27023fAd1a09f587c5A71
(feel free to send some ETH)
Step 3: Making the QR code
Making a qr code is a straightforward process. You are just encoding the Address that we printed out above into the QR format.
There are plenty of methods. I use the free site qr-code-generator.
Just download the QR code .png file and move it to the flashdrive.
This technically doesn’t add any capabilities, it just saves us the effort of having to retype the address on other devices, which we deal with next.
This QR code can be sent out freely. Anyone with access can send you ETH, but not take any.
Step 4. Send ETH in and out of the wallet
You could just load up all of the ETH onto this wallet right away. But if you’re anything like me, you might want to test it with a small amount first. So I’ll show you not only how to get ETH into the wallet but also out.
Send a little test transaction to the wallet, and get it off. Don’t be mad at me if you did something real wrong.
Putting some on
You need to buy some ETH from someone. Robinhood, venmo, coinbase, etc will sell you some. You can either pay someone cash to send it to you, or you can purchase it on a wallet through one of these services, and then send it from your wallet to this wallet.
It just needs to be directed to the wallet address we created. Scan the QR code to see it, or just copy and paste the raw address.
There’s no private code needed from the flashdrive for this. In fact you could forever unplug the flashdrive from the computer at this point and still receive ETH indefinitely. You only need to plug the flashdrive back in when you want to remove some of it.
Sending out of this wallet
Once you have a small amount in the wallet, which you can verify with etherscan.io, then we can use our final bit of code to send money off. (ps, it takes a few minutes to show up sometimes)
Now the caveat with this program (which I wrote), is that you have to manually set the price of gas that you are willing to spend.
You can track gas prices here: https://etherscan.io/gastracker.
And you can learn what an ethereum gas price even is here.
so here’s the code:
import sys
from web3 import Web3
from eth_account import Account
import subprocess
# Connect to an Ethereum node (use Infura, Alchemy, or a local node)
w3 = Web3(Web3.HTTPProvider("https://ethereum.publicnode.com"))
# Extract the private key in hex format
cmd = "openssl ec -in private-key.pem -text -noout | grep priv: -A 3 | tail -n +2 | tr -d ' \n:'"
private_key = subprocess.check_output(cmd, shell=True, text=True).strip()
# Ensure the private key is exactly 64 hex characters (Ethereum private key format)
if len(private_key) != 64:
raise ValueError(f"Invalid private key length: {len(private_key)} characters")
# Derive the public Ethereum address
account = Account.from_key(private_key)
sender_address = account.address
print("Please check gas prices before executing: https://etherscan.io/gastracker.\n")
gas_price_chosen = float(input("What Gas price do you want to pay? "))
if (gas_price_chosen > 2):
raise Exception("That gas price seems a little high, you'll have to manually override")
destination = input("Destination Address: ")
destination_conf = input("Confirm Destination Address: ")
if (destination != destination_conf):
print("Destination Confirmation Failed to Match")
sys.exit(0)
print("\nCurrent Balance: ", w3.from_wei(w3.eth.get_balance(sender_address), 'ether'))
amount = input("Amount to Send (in ETH): ")
print(f"\n\nSet to send {amount} $ETH to address {destination}")
confirm = input("Confirm? (y/n)")
if (confirm != 'y'):
print("transaction not confirmed")
sys.exit(0)
# Define the transaction
tx = {
'to': destination, # Change to your receiving address
'value': w3.to_wei(amount, 'ether'), # Amount to send (0.01 ETH example)
'gas': 21000, # Standard gas for ETH transfer
'gasPrice': w3.to_wei(gas_price_chosen, 'gwei'), # Adjust gas price if needed
'nonce': w3.eth.get_transaction_count(sender_address),
'chainId': 1 # Mainnet (use 5 for Goerli testnet)
}
# Sign the transaction
signed_tx = Account.sign_transaction(tx, private_key)
# Send the transaction
tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
# Print the transaction hash
print(f"Transaction sent! Track it at https://etherscan.io/tx/{tx_hash.hex()}")
And here is what it looked like when I ran it
README
And well, that would pretty much be it. Except for that I add one more file to help me remember all of this, the README.md file. Feel free to use this template:
My Ether
Ethereum Address: YOUR_WALLET_ADDRESS_HERE
Track transactions: https://etherscan.io/address/{YOUR_WALLET_ADDRESS_HERE}
Sending Money
Execute the program send_eth.py using
python3 send_eth.py
Note: your computer needs to be able to run python and have a few package dependencies that can be installed via pip.
This program will prompt you for the destination address and amount in ETH, and then send the transaction. Check the current gas prices and adjust the program accordingly before sending: https://etherscan.io/gastracker.
Keys
Keys generated March 14, 2025
IMPORTANT Anyone with access to the keys will be able to send ETH out of this wallet.
Private key in Hex:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This can be printed at anytime from the private key using
openssl ec -in private-key.pem -text -noout | grep priv: -A 3 | tail -n +2 | tr -d '[:space:]:'