Skip to content

Instantly share code, notes, and snippets.

@yorickdowne
Last active March 11, 2023 06:42
  • Star 16 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Get that sweet Sepolia ETH

Sepolia is now on PoS

As of 2022/7/6, Sepolia has switched to PoS. The window to do some mining has closed.

Testnets after merge (original, old content from here)

It's mid 2022, Ethereum is still PoW and motoring towards merge / PoS. Surviving testnets will be Sepolia - currently PoW - and Goerli. Ropsten will be merged and then deprecated, Rinkeby and Kovan won't be merged.

I want to "get ready" for some Sepolia testing pre- and post-merge. Sepolia will not have a public validator set; testing post-merge will be limited to running applications on it. As Sepolia is PoW, I can actually go mine myself some SepplETH. Here's how.

Components

  • Geth on Sepolia, Linux. This could absolutely be Windows, I just happen to have Linux tooling I like
  • ethminer or t-rex, Windows, with an NVidia or AMD GPU. Mostly because the only GPU I have that can mine is in my Windows box

Set up Geth

I'm using eth-docker for this.

Get prereqs: sudo apt update && sudo apt install -y docker-compose

Make your user part of the docker group so you don't need sudo for docker commands: sudo usermod -aG docker MYUSERNAME && newgrp docker

Clone eth-docker: git clone https://github.com/eth-educators/eth-docker.git sepolia && cd sepolia

Configure eth-docker for this: cp default.env .env, then nano .env and set

  • COMPOSE_FILE=geth.yml:el-shared.yml
  • EL_NETWORK=sepolia

Save and close.

Get the ETH address you want the Sepolia mining rewards to be sent to. Anything created in Metamask will do.

A few changes for Geth so it can mine. nano geth.yml and change the entrypoint. Enable the miner API, and append to it:

    entrypoint:
      - geth
      .... existing entries, leave those be
      - --http.api
      - web3,eth,net,miner
      .... existing entries, leave those be
      - --pprof.addr
      - 0.0.0.0
      - --mine
      - --miner.etherbase
      - "0xMYETHADDRESS"

You need the quotes around the address, and 0xMYETHADDRESS is going to be your actual address.

Start it: ./ethd up, and look at the logs with ./ethd logs -f execution. It should sync the chain in minutes and then be ready for mining.

Firewalling

If your Linux boxen is on the Internet, not in your home network, and only then, you'll want to firewall the RPC port 8545 and WS port 8546, which are both exposed now. Follow instructions to place ufw "in front of" docker, get the public IP your Windows box uses with something like whatismyip and create a simple policy along these lines:

sudo ufw allow OpenSSH
sudo ufw allow proto tcp from MYPUBLICIP to any port 8545
sudo ufw deny 8545
sudo ufw deny 8546

And finally sudo ufw enable. Adjust the policy to your own needs if you already had ufw running.

Connect Metamask to Sepolia

In Metamask, go to Settings, Network, Add Network and create a new custom network.

Call it Sepolia Test Network, set the New RPC URL to your Sepolia Geth as http://IP-OF-GETH-BOX:8545, Chain ID 11155111, currency symbol SepplETH and Explorer to https://sepolia.etherscan.io.

Windows mining

Your AntiVirus and browser will likely quarantine these as cryptominers, because they are. You'll need to allow-list them.

Grab ethminer. It's open source, but doesn't work with newer-generation cards. A PR that enables CUDA11 and thus RTX 3000 series does exist, but there are no ready-made executables for it.

Extract that somewhere, get into a PowerShell or create a bat file, then start it like so: For NVidia, .\ethminer.exe -U -P getwork://IP-OF-GETH-BOX:8545 or for AMD, .\ethminer.exe -G -P getwork://IP-OF-GETH-BOX:8545.

You can get help with .\ethminer.exe --help.

An alternative is t-rex, which is closed-source. It takes a 1% dev cut, and supports newer-generation cards. Download it, then run it in PowerShell or via bat as .\t-rex.exe -a ethash -o http://IP-OF-GETH-BOX:8545.

You can get help with .\t-rex.exe --help.

In my testing both ethminer and t-rex get almost the same hashrate from GTX 1080 and GTX 1070, with T-Rex ahead by maybe 5%. T-Rex does have a nice UI.

Done

In your Geth logs, you should see 🔨 mined potential block and 🔗 block reached canonical chain as well as the occasional ⑂ block became an uncle, and in ethminer you should see Job: and **Accepted messages.

Enjoy the feeling of early Ethereum mining. Difficulty on Sepolia is low, you should see rewards come in steadily.

@yorickdowne
Copy link
Author

@Hua-Yen As far as I know, there is currently no reliable Sepolia Faucet. ethstaker Discord will run one, but we need Infura to offer a Sepolia endpoint, first. The ethstaker faucet will be protected by BrightID for Sybil resistance. It is incredibly hard to operate a faucet and keep it operational, because bots will attempt to drain it.

@yorickdowne
Copy link
Author

There was likely a mistake when updating geth.yml. git restore geth.yml and then just ./ethd config to run an RPC node on Sepolia. Sepolia mining is no longer possible, nor is validating.

@matewilk
Copy link

matewilk commented Nov 2, 2022

Hey, is it possible to run it on a Mac?

I'm trying to run it on MacOS but getting the following error:

$ ./ethd install
./ethd: line 1526: syntax error near unexpected token `&'
./ethd: line 1526: `            ;;&'

@avdheshcharjan
Copy link

same here

@qjawe
Copy link

qjawe commented Nov 6, 2022

I can't run ./ethd install neither ./ethd up
It shows this error

./ethd install
./ethd: line 1548: syntax error near unexpected token `&'
./ethd: line 1548: `            ;;&'

@avdheshcharjan
Copy link

Using MacBook Air M1 and having the same issue!

I can't run ./ethd install or ./ethd up
It shows this error

./ethd install
./ethd: line 1548: syntax error near unexpected token &' ./ethd: line 1548: ;;&'

@yorickdowne
Copy link
Author

There are faucets for Sepolia ETH, see https://faucetlink.to

As for Mac M1 and eth-docker: eth-docker uses some bash-isms and gets tested on Linux. I don't have a Mac to test on, alas, so it working on Mac is more miss than hit.

@qjawe
Copy link

qjawe commented Nov 29, 2022

faucets for Sepolia ETH, see https://faucetlink.to/ could not get more than 100 of SepoliaETH faucet

@yorickdowne
Copy link
Author

Which is more than enough. Gas on Sepolia is cheap. That's enough for a ton of contract deployments and testing.

@0xolishell
Copy link

0xolishell commented Mar 6, 2023

[March 2023 Update] Here is Alchemy's Sepolia faucet – https://sepoliafaucet.com. It's free and you can get more every day if you need. Adding b/c I'm seeing people posting about needing Sepolia ETH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment