Create your own Tokens using Foundry

Why we are here, and what we are creating

If you are interested in getting stuck into this lesson, you would have at least completed our Lesson 1, Getting Started with Smart Contract Development, if not also lessons 2 and 3 on building NFTs*.* Or you already have a reasonable idea of what a smart contract is, are familiar with at least some basic developer tooling and have grasp of some fundamental web3 principles. **

By the end of this lesson you will be able to create your own ERC20 token, and be able to change its properties in any way you need. We’ll also give some suggestions on how to creatively take that a few steps further. In this lesson we’ll be using Foundry Book as our toolkit/tools for building.

Let’s have a look at some rationale before we get stuck into the actual content of the project, so we’re all speaking the same language.

Tokens, crypto, coins, ERC20, is it all the same?

The Ethereum blockchain, and most EVM-compatible blockchains, have a native utility token, or more accurately coin, that is used to pay for transaction costs, and also to reward validators in Proof of Stake (previously miners in Proof of Work). On Ethereum that native coin is Ether, or ETH. In Polygon it’s MATIC, on Avalanche it’s AVAX, and so on. Let's focus on the Ethereum blockchain for the sake of clarity.

Every other crypto or token you see, use or interact with on Ethereum is basically a smart contract that lets you send, receive, and check your balance of that token.

Stablecoins like DAI, Tether (USDT), USD Coin (USDC), or tokens from projects like Uniswap (UNI), MakerDAO (MKR), Basic Attention Token (BAT) are all smart contracts that follow a standard. The ERC20 standard.

Why would we want to create yet another token?

A lot of reasons, but here are some types of utility it could offer us:

The possibilities are endless.

What do we need to do with our token?

Some basic functionality that our token needs to provide is: