DEV Community

Bagas Hariyanto
Bagas Hariyanto

Posted on

14 Days Journey Learn Web3

I just completed an intensive 14-day dive into Web3, and it's incredible how much I've learned. I went from understanding the basic concepts to actually building my own tokens. Here’s a breakdown of my journey and what I mastered over the two weeks.

Week 1: Mastering Solidity & Smart Contract Fundamentals

My first week was all about building a strong foundation. I focused on Solidity, the primary programming language for the Ethereum blockchain.

Setting Up My Environment: First, I got my tools ready. I learned to use the Remix IDE, a fantastic browser-based tool for writing and testing contracts. I also set up my MetaMask wallet to interact with the network and used a Sepolia faucet to get free "test" ETH. This was crucial so I could deploy contracts without spending real money.

Solidity 101 (The Basics): I started with the essential building blocks of the language. I now understand the core data types:

string: For text.

uint256: The standard for numbers, like IDs or balances.

bool: For simple true/false values.

address: A special type for holding Ethereum wallet addresses, including the critical msg.sender (who is calling the function).

Organizing Complex Data: Once I had the basics, I learned how to structure data effectively.

struct: This was a breakthrough. It lets me create my own custom data types, like a Student struct that groups an ID, name, and wallet address.

mapping: This is the most common way to store and retrieve data. I learned to think of it as a "dictionary" that links a key (like a student ID) to a value (like their Student struct).

enum and array: I also learned to use enums for predefined states (like Active or Graduated) and arrays for dynamic lists.

Contract Logic & Security: Finally, I learned how to make my contracts do things and how to keep them safe.

require(): This is my most important security tool. I learned to use it to check conditions (like require(balance >= amount)) before allowing a function to continue.

modifier: I learned how to create reusable checks, like the classic onlyOwner modifier, to lock down administrative functions.

event: I learned how contracts "talk" to the outside world by emitting events, which are essential for any user interface.

payable: I now know how to write functions that can receive Ether.

By the end of week one, I had successfully written, deployed, and interacted with my own StudentRegistry smart contract. I was no longer just reading about blockchain; I was writing to one.

Week 2: Building My Own Tokens (ERC20 & ERC721)

In my second week, I took my new Solidity skills and applied them to one of the most exciting parts of Web3: tokens. I focused on the two main standards.

Part 1: ERC20 (Fungible Tokens):

I learned that ERC20 is the standard for "fungible" tokens, where every token is identical, like a dollar bill. This is what stablecoins (USDT) and utility tokens (LINK) use.

I built my own ERC20 token from scratch. This was a fantastic exercise where I had to implement:

A mapping (using balanceOf) to track how many tokens each wallet holds.

A transfer function to let users send tokens to each other.

The approve and transferFrom flow. This was a key concept, as it's what allows other smart contracts (like decentralized exchanges) to spend tokens on my behalf.

Part 2: ERC721 (Non-Fungible Tokens - NFTs):

Next, I tackled ERC721, the standard for NFTs. I learned that "non-fungible" means each token is unique and has a specific owner, identified by a tokenId.

This was the most fun part. I built my own CryptoKitty-style NFT contract. This was more complex and taught me to:

Use a mapping (for ownerOf) to track the owner of each unique NFT.

Write a _mint() function to create new NFTs, often with unique properties.

Implement safeTransferFrom to securely transfer NFT ownership.

I even experimented with a breed() function to create a new, unique NFT from two "parent" NFTs.

Putting It All Together: OpenZeppelin

Finally, I learned the most important lesson for real-world development: don't write these from scratch in production!

I was introduced to OpenZeppelin Contracts, a library of secure, audited, and optimized smart contracts. I learned how I can create a production-ready ERC20 or ERC721 token in just a few lines of code by simply importing from their library. This is how I'll build projects moving forward.

After this 14-day journey, I've gone from being a curious outsider to someone who has successfully built and deployed their own fungible tokens and NFTs. I have a solid, practical skill set and I'm excited to keep building in Web3.

Top comments (0)