Motivation
This series of tutorial documents my process of building an Ethereum faucet on the Ropsten Testnet. The development of a faucet was borne out of necessity. In my regular engagements and workshops, I frequently give out ETHs to participants to let them try out stuff. But being new to these things, it isn't so straightforward to simply transfer ETHs to them. And sometimes, the various Ropsten faucets out there don't perform too reliably.
So I built my own faucet.
This tutorial will be presented in 4 parts:
- Ropsten Ethereum Faucet: How it works
- Ropsten Ethereum Faucet: Smart Contract
- Ropsten Ethereum Faucet: JSON Web Service
- Ropsten Ethereum Faucet: Web App
Faucet Logic
Here's how my Ropsten Faucet works. In designing the faucet, I decided that the user should be able to receive free ETHs simply by telling the Faucet his Ropsten wallet's address. And he should be able to do so without needing to have an Ethereum wallet such as MetaMask connected to his browser.
In the Faucet Web App, the requester enters his address and state the amount of ETHs he wishes to receive.The Faucet Web App makes a call to Ropsten Faucet, a Node.JS-based JSON Web Service that is running on Glitch.com. The Web Service makes a Smart Contract call to the Faucet Smart Contract on the Ropsten Testnet to request a transfer. The Faucet Smart Contract then performs a transfer of the requested ETH to the requester's wallet address.
Since the call to transfer ETH from faucet to wallet will incur transaction fees (and I couldn't let the requester fund his own ETH transfer), a wallet is set up to fund these transfers in the Faucet JSON Web Service.
Getting Free ETHs
Here's how to get your free ETH. Visit Ropsten Faucet on Glitch.com to make sure that the Faucet Web Service is awake. Here's the screenshot you will see if it is awake and raring to go. If it isn't awake, visiting it will wake it up.
Next, visit the Faucet Web App. Check that the Faucet does indeed contain ETH for you to pick up. The screenshot below says that there are 4 ETHs in the faucet. If you don't see any ETHs here, then it's time to contribute some. Scroll down the section on "Donating ETHs" for instructions on how you can give some ETHs to the faucet. Alternatively, drop me a note and I will replenish it.
You need to know your wallet's address. Here's how to retrieve it if you are using MetaMask. Make sure that you are on the Ropsten Testnet. Then click your address to copy it.
Paste your address into the Faucet's Wallet Address text field. Then click [Go].
Hang on for a while. You should see new ETHs in your wallet.
Donating ETHs
Here's how you can donate ETHs to the Ropsten Faucet. Visit the Faucet Smart Contract on Etherscan.
You can only do this if you have a Ethereum Wallet plugin such as MetaMask connected in your browser. Click "Contract", followed by "Connect to Web3".
Then click "Write Contract". Enter the amount of ETH you wish to contribute to the faucet and click [Write].
Confirm the transfer.
Then visit the Faucet Web App again. Thank you for your contribution to the Ropsten Faucet!
What's Next?
The source codes for this projects can be found in my Github repository.
In the next part of this tutorial, I will explain the codes behind the Faucet Smart Contract. Stay tuned!
If you enjoyed this tutorial, perhaps you may also wish to read:
- Voting on a Blockchain: An implementation of a Voting DApp on Ethereum.
- Minimum Viable Ethereum Mobile Wallet: A React Native-based template that I constructed for projects that require a mobile Ethereum wallet.
- Deploy a Private Ethereum Blockchain in 10 Minutes with Kaleido: Getting a private Ethereum Blockchain up and running in a jiffy.
- Smart Contract Explained by Demonstration: A demo of an Escrow Service Smart Contract DApp - in my opinion, the fastest way to explain to a layman, what Blockchain is.
- Ethereum IOT Kid Grounding Device: My attempt to incorporate Blockchain with Internet of Things.
- Lottery as a Smart Contract: Distributed Lottery, an attempt to build a lottery system on the Ethereum Blockchain.
Photo by Kazuky Akayashi on Unsplash
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Icons made by Smashicons from www.flaticon.com is licensed by CC 3.0 BY