♈
Bootcamp-2024
  • Intro
  • 1. Blockchain & Wallet Fundamentals
    • Blockchain Introduction
    • State Machines
    • Cryptography
    • Distributed Networks
    • Game Theory
    • What is Web3
    • MetaMask Wallet Installation
    • Transferring Tokens with MetaMask
  • 2. Smart Contract & Solidity Fundamentals
    • Using Remix
    • Create, compile and publish your first smart contract
    • Interact with already published smart contracts
    • Blockchain Explorer
    • Verify source code on Etherscan
  • 3. Oracles, ERC20 & Chainlink Data Feeds
    • Oracles
    • Create & Deploy ERC20
    • Data Feeds
  • 4. Cross-Chain Tokens With Chainlink CCIP
    • Setting up MetaMask
    • Getting USDC Testnet Tokens
    • Create Smart Contract In Remix
    • Compile and Deploy
    • Approve USDC
    • Send LINK to your Contract
    • Send USDC from Fuji to Sepolia
    • USDC on Sepolia
  • 5. Mentoring Session
  • 6. NFTs & Chainlink Automation
    • NFT Basics
    • Dynamic NFTs
    • Creating an NFT Smart Contract
    • Deploying Your Dynamic NFTs
  • 7. Chainlink CCIP & Cross-Chain NFT dApps
    • Create and deploy CCIP NFT Contracts
    • Mint on Source Chain
    • Fund Contract
    • Mint On Sepolia From Fuji
    • Mint from Destination 2 - Base Sepolia
  • 8. Random Numbers with Chainlink VRF
    • Introduction to Chainlink VRF
    • Hands On Game Using VRF
  • 9. Off-Chain Data with Chainlink Functions
    • Chainlink Functions Playground
    • Setting up MetaMask
    • Remix
    • Functions Subscription
    • Creating The Functions Consumer Contract
    • Sending a Request from Remix
    • City Weather and Examples
    • City Weather on Chainlink Functions
  • 10. Connecting the 🌏 with Chainlink
  • Glossary
Powered by GitBook
On this page
  • These resources will guide you on your journey through this workshop while also allowing you the opportunity to dig a little deeper on these subject matter.
  • UPDATING TOKEN INFO
  • MINTING TOKENS
  1. 3. Oracles, ERC20 & Chainlink Data Feeds

Create & Deploy ERC20

In this section we will go over how to create and deploy our own ERC20 token using the existing ERC20 Token Standards!

PreviousOraclesNextData Feeds

Last updated 1 year ago

Before we get started I would like to give you some important links for ERC20 Tokens

These resources will guide you on your journey through this workshop while also allowing you the opportunity to dig a little deeper on these subject matter.


As we begin our Workshop and learn to create and deploy your very own ERC20 Token, we will use the Remix in-browser IDE.

When you enter the Remix IDE, make sure you are in DEPLOY & RUN TRANSACTIONS view on the left.

Ensure your environment is selected as the "Injected Provider - Metamask", and you're connected to the Ethereum Sepolia testnet; Network Id - (11155111)

This workshop takes place on the Sepolia Testnet, so we will also make sure that the network we are connected to reflects that. Sepolia Network Id - (11155111)

Next we will be creating our own Token.sol smart contract within Remix.

In the Remix FILE EXPLORER, you will create a new file and name that file Token.sol

You will create a new file and name that file Token.sol

The Token.sol code looks like this

// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts@4.6.0/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts@4.6.0/access/AccessControl.sol";

contract Token is ERC20, AccessControl {
	bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

	constructor() ERC20("Chainlink Bootcamp 2024 Token", "CLBoot24") {
    	_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    	_grantRole(MINTER_ROLE, msg.sender);
	}

	function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
    	_mint(to, amount);
	}

	function decimals() public pure override returns (uint8) {
    	return 2;
	}    
}

You can also find the code here in this Github Repository


UPDATING TOKEN INFO

You may choose your own Token name and symbol by changing the inputs in the constructor() function. You can give your token whatever name and token symbol you like!

On the first line of the constructor function, which is the first function ran upon contract deployment. A constructor function is only run once.

constructor() ERC20("Chainlink Bootcamp 2024 Token", "CLBoot24") {

Switch to the Solidity Compiler; the icon on the left of the Remix IDE that looks like a "S". Make sure you check the auto-compile box, so that you don't have to keep manually clicking the compile button each time you write new lines of code!

To confirm that your contract has been compiled properly you want to see that Green Check Mark on the lefthand side.


Switch to the Deploy & Run Transactions tab - the 5th Icon and click the Deploy button

Upon clicking the deploy button, it will bring up Metamask and ask you to confirm the transaction.


When your transaction is confirmed you can find the UI for interacting with your deployed contract at the bottom lefthand side of the REMIX IDE


Now we are going to import our newly created Token to our Metamask Wallet & Mint 100 Tokens to ourselves

First we will want to copy our Token Address from the Remix UI's button.

Open your Metamask and make sure the tokens tab is opened

Scroll to the bottom and select the "Import tokens" option

Paste your Token Address into the TToken Contract Address Field within the Import Tokens page in Metamask. You may pause a couple of seconds for Metamask to grab data from your deployed contract and full up those text boxes.

Confirm and Import the token into your Metamask


MINTING TOKENS

We will interact with our deployed ERC20 token contract and mint 100 tokens for ourselves (our wallet).

Go to the REMIX IDE and click on the DEPLOYED CONTRACTS Icon on the lower lefthand side of the screen.

Expand the Token.sol contract that you've just deployed.

We will be using the orange colouredmint() function. To the right of the input box click on the down pointing arrow to see all the inputs that function expects.

The parameters required for the Mint function is as follows

to: your wallet address

amount: 10000

We use 10000 as the amount because in our contract we have a function which declares the amount of decimal points our custom ERC20 token has. We went with 2 because we wanted it to be as close to Fiat currencies as possible. Solidity doesn't work well with floating point numbers (numbers with decimal points like 100). So in Solidity , $100 would be represented as 100 x (10^N) where N is the number of decimal places.

Our custom token has 2 decimal places, so 100 of our token would be represented in solidity as 100 x (10^2) which is 100 x 100 or 10,000.

It's worth noting that many ERC tokens and native tokens like Ether have 18 decimal places!

Make sure to copy your wallet address by opening your Metamask and clicking this field

or you can copy it directly from the REMIX IDE

Click the Transact button within the Mint Function and confirm the transaction when Metamask pops open.


To check the balance of your token within your wallet you will use the balanceOf Function with your wallet address as the parameter. You'll see the quantity of tokens that you have just created and minted into your Wallet.

Do not deploy this contract yet - we'll get there

😄
Token Standards | ethereum.orgethereum.org
Many Ethereum development standards focus on token interfaces. These standards help ensure smart contracts remain composable, so for instance when a new project issues a token, that it remains compatible with existing decentralized exchanges
EIP-20: Token StandardEthereum Improvement Proposals
A standard interface for fungible (interchangeable) tokens, like voting tokens, staking tokens or virtual currencies
OpenZeppelin Contracts Wizard
An interactive smart contract generator based on OpenZeppelin Contracts that allows users to create tokens using standards, ensuring composability
Remix - Ethereum IDE
OPEN THIS LINK!
chainlink-bootcamp-2024/Token.sol at main · solangegueiros/chainlink-bootcamp-2024GitHub
Token.sol Source Code
Logo
Logo
It should look something like this
Selecting File Explorer
Creatinig a new File
A new File in your File Explorer should look like this
It should look like this
Example of Metamask Transaction Confirmation
Your deployed contracts will appear here
This is how you would copy the address of your token
Token Tab in Metamask
Import Tokens will appear near the bottom of the Tokens tab within Metamask
It should look something like this
It should look like this
Example of an expanded deployed Token Contract within the REMIX IDE
Example of expanding the Mint Function so we can input the parameters required
Example of filled in parameters for Mint Function
Clicking your wallet address in Metamask like this will Copy it to your clipboard
You can also copy through clicking this clipboard button within the REMIX IDE
balanceOf Example
Logo
Logo