100 Days of Web3 (Days 91-100)
I’ve finally come to the end of the 100 Days of Web3 challenge. I’ve learnt so much during this time and yet feel that I’ve barely scratched the surface. During the last ten days of the challenge, I finished up with my custom layer two token project and prepared a lunch and learn session to teach my teammates how to create an ERC-20 token.
Day 91
On day 91, I ran into some issues with the scripts I had written for token deposits and withdrawals on Optimism. The tokens appeared to be deployed correctly, and yet when I tried to move tokens between Ethereum and Optimism, I kept running into an error. It turned out that there was a pretty basic bug in my script where the transaction was always executed on Optimism instead of Ethereum. I tried logging additional information from the script which didn’t help much. I discovered the bug when I wasn’t able to find the contract address for the token on the Ethereum block explorer. That’s when I realized the token contract was being created on Optimism instead!
Day 92
Previously, I had temporarily abandoned my custom token implementation on Arbitrum as I kept having errors with the deployment script. I found that the Arbitrum team had updated their official tutorial repository to use the new Arbitrum SDK. When I had tried to run their previous custom token example, it was failing with an error, so I decided to try again with the new SDK. I cloned the repo locally, set up the config and tried to run the updated example for a custom token. I ran into a different error, but this time I was able to come up with a fix. I created a pull request on the official tutorial repository which was accepted. Although it was a very simple fix, I was pretty pleased with myself for contributing to the official tutorial repository.
Day 93
Next, I fixed all of my scripts for my custom Arbitrum token by updating them to use the new Arbitrum SDK. I wrote a few different scripts to demonstrate the functionality:
- deploy.js
- Deploys token on Ethereum and Arbitrum and configures the contracts to use the bridge
- deposit.js
- Transfers tokens from Ethereum to Arbitrum
- 1-withdraw.js
- Begins the transfer of tokens from Arbitrum to Ethereum
- 2-withdraw.js
- Uses Arbitrum outbox contract to complete the token withdrawal
The dispute time on the Arbitrum testnet is 1 day, so I couldn’t fully test the withdrawal on the same day. I just initiated a lot of withdrawals so that I could easily troubleshoot any issues on a subsequent day.
Day 94
I fixed some minor bugs on the final Arbitrum withdrawal script and was able to transfer the tokens back to Ethereum. I was finally finished with the Arbitrum implementation of my custom token. I started to look at the Optimism examples in preparation for completing the same token implementation on Optimism.
Day 95
I created a readme file with instructions on running the Arbitrum custom token implementation. I made sure to include directions for deploying the tokens, depositing them to Arbitrum and withdrawing them back to Ethereum. I also created an top-level readme for the project which links to the token implementation for each layer two chain.
Day 96
I started the Optimism implementation for the custom token by creating the smart contracts first. The contract for the token on Ethereum was just a standard ERC-20 contract. The token contract on Optimism was the same but had a few additional methods to mint and burn tokens. Those additional methods were only callable by the Optimism bridge.
Day 97
I wrote the scripts for deploying the custom token, depositing the tokens from Ethereum to Optimism and withdrawing them back from Optimism to Ethereum. I then created a readme file with instructions on how to run the solution including all the scripts. My layer two custom token project was finally complete and had been deployed to three different layer two chains!
Day 98
The opportunity came up to do a lunch and learn at my current job. I realized that teaching others about blockchain would be a great way to finish up with the 100 Days of Web3 challenge. I decided to make the goal of the lunch and learn to deploy a basic ERC-20 token. This seemed pretty ambitious for an audience that may not be familiar with blockchain, but ERC-20 tokens are relatively simple and I thought my team could handle it.
In order to teach someone to create an ERC-20 token, they need to learn several concepts in Solidity first. I knew that I would have to spend most of the lunch and learn focusing on Solidity code in order to get the lesson done in a timely fashion. However, I started by creating some slides to give some basic context on blockchain, Ethereum, smart contracts and tokens. The goal was to spend less than 5-7 minutes on the slides.
Day 99
There were a few concepts that I needed to teach before showing the final ERC-20 token code. I created examples and exercises for each of the following concepts in Solidity:
- Functions
- Validation
- Addresses
- Mappings
- Events
You can find all of the code in a repository I created here.
Day 100
The final part of the lunch and learn was coding the ERC-20 token itself. In order to save time, I decided that we might have to skip the implementation for the approval functionality of ERC-20. I broke down the implementation of the simplified ERC-20 token into 6 steps:
- Create three public fields with initialized values: name, symbol and decimals.
- Create one more public field called totalSupply without an initialized value.
- Create a mapping that represents the token balance of each address.
- Create a constructor which initializes the totalSupply field and assigns the deploying address the full supply.
- Implement the balanceOf method which returns the balance of a particular address.
- Implement the transfer method which allows a user to transfer tokens to a different address.
That completed my preparation for the lunch and learn. All that remained was to present it!
Summary
It’s hard to believe that these hundred days have passed by so quickly. I can still remember the first day of the challenge when I was progressing through the Udemy Ethereum course. Of course, the end of the 100 Days of Web3 challenge is not the end of my Web3 learning journey. There is so much more to investigate, learn and build, and I look forward to doing that.