> For the complete documentation index, see [llms.txt](https://cll-devrel.gitbook.io/bootcamp-2024/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cll-devrel.gitbook.io/bootcamp-2024/3.-oracles-erc20-and-chainlink-data-feeds/create-and-deploy-erc20.md).

# Create & Deploy ERC20

Before we get started I would like to give you some <mark style="color:blue;">important links for ERC20 Tokens</mark>&#x20;

{% embed url="<https://ethereum.org/en/developers/docs/standards/tokens/>" %}
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
{% endembed %}

{% embed url="<https://eips.ethereum.org/EIPS/eip-20>" %}
A standard interface for fungible (interchangeable) tokens, like voting tokens, staking tokens or virtual currencies
{% endembed %}

{% embed url="<https://wizard.openzeppelin.com/>" %}
An interactive smart contract generator based on OpenZeppelin Contracts that allows users to create tokens using standards, ensuring composability
{% endembed %}

## 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.&#x20;

***

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

{% embed url="<https://remix.ethereum.org>" %}
OPEN THIS LINK!&#x20;
{% endembed %}

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)

<figure><img src="/files/zyZuXFpl3dUMARBM6GlJ" alt=""><figcaption><p>It should look something like this</p></figcaption></figure>

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

<figure><img src="/files/w52Kg7T3VWfMRV7zkXsM" alt=""><figcaption><p>Selecting File Explorer</p></figcaption></figure>

<figure><img src="/files/kaJWVHJ4yIHo2bRSrj7P" alt=""><figcaption><p>Creatinig a new File</p></figcaption></figure>

<figure><img src="/files/nnIWo1hSphhmMcU3Lnrc" alt=""><figcaption><p>A new File in your File Explorer should look like this</p></figcaption></figure>

The <mark style="color:blue;">Token.sol</mark> code looks like this

```solidity
// 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 <mark style="color:blue;">Github Repository</mark>

{% embed url="<https://github.com/solangegueiros/chainlink-bootcamp-2024/blob/main/Token.sol>" %}
Token.sol Source Code
{% endembed %}

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

***

## 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.&#x20;

```solidity
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!

<figure><img src="/files/OuCwAF5yfXCM4lT4UJlq" alt=""><figcaption><p>It should look like this</p></figcaption></figure>

To confirm that your contract has been compiled properly you want to see that <mark style="color:green;">Green Check Mark</mark> on the lefthand side.

***

Switch to the <mark style="color:blue;">Deploy & Run Transactions</mark> tab - the 5th Icon and click the <mark style="color:orange;">Deploy button</mark>

<figure><img src="/files/W3I52AN09YpZaJGxFiqR" alt=""><figcaption></figcaption></figure>

Upon clicking the <mark style="color:orange;">deploy button</mark>, it will bring up <mark style="color:red;">Metamask</mark> and ask you to <mark style="color:red;">confirm the transaction</mark>.

<figure><img src="/files/4g9rbsWFXufCZ7IOFtma" alt=""><figcaption><p>Example of Metamask Transaction Confirmation</p></figcaption></figure>

***

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

<figure><img src="/files/I4RYJLBgFRQO6Tt0MZcH" alt=""><figcaption><p>Your deployed contracts will appear here</p></figcaption></figure>

***

Now we are going to import our newly created <mark style="color:blue;">Token</mark> to our <mark style="color:red;">Metamask Wallet</mark> & <mark style="color:orange;">Mint</mark> 100 Tokens to ourselves

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

<figure><img src="/files/0ZjhQ15PYWJ7oyKrCOTO" alt=""><figcaption><p>This is how you would copy the address of your token</p></figcaption></figure>

Open your <mark style="color:red;">Metamask</mark> and make sure the <mark style="color:blue;">tokens tab</mark> is opened

<figure><img src="/files/mP8GWSQlA0dQGK4QIMzy" alt=""><figcaption><p>Token Tab in Metamask</p></figcaption></figure>

Scroll to the bottom and select the <mark style="color:blue;">"Import tokens"</mark> option

<figure><img src="/files/O616XBCQK3VDqDX0BLbV" alt=""><figcaption><p>Import Tokens will appear near the bottom of the Tokens tab within Metamask</p></figcaption></figure>

Paste your <mark style="color:yellow;">Token Address</mark> into the T<mark style="color:yellow;">Token Contract Address</mark> Field within the <mark style="color:blue;">Import Tokens</mark>  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.

<figure><img src="/files/KVWPjCT044j5kNMWVXSG" alt=""><figcaption><p>It should look something like this</p></figcaption></figure>

<mark style="color:green;">Confirm</mark> and <mark style="color:blue;">Import the token</mark> into your <mark style="color:red;">Metamask</mark>

<figure><img src="/files/RI5dmNJobttUkMXbrL5Y" alt=""><figcaption><p>It should look like this</p></figcaption></figure>

***

## 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 <mark style="color:blue;">Token.sol contract</mark> that you've just deployed.

<figure><img src="/files/MLwpABtADqfcX2Dl1ekk" alt=""><figcaption><p>Example of an expanded deployed Token Contract within the REMIX IDE</p></figcaption></figure>

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

<figure><img src="/files/kZeRQ1gk2zm7CEdJM5r8" alt=""><figcaption><p>Example of expanding the Mint Function so we can input the parameters required</p></figcaption></figure>

The <mark style="color:orange;">parameters</mark> required for the <mark style="color:orange;">Mint function</mark> is as follows

`to`: <mark style="color:yellow;">your wallet address</mark> &#x20;

<mark style="color:orange;">amount</mark>: <mark style="color:yellow;">10000</mark>

We use <mark style="color:yellow;">10000</mark> as the amount because in our contract we have a <mark style="color:orange;">function</mark> 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 <mark style="color:red;">floating point numbers</mark> (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. &#x20;

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!

<figure><img src="/files/7MjPT6434Bd1N5yIuS9y" alt=""><figcaption><p>Example of filled in parameters for Mint Function</p></figcaption></figure>

Make sure to copy your <mark style="color:yellow;">wallet address</mark> by opening your Metamask and clicking this field

<figure><img src="/files/AjkCm3ohMmiqZPcEzupE" alt=""><figcaption><p>Clicking your wallet address in Metamask like this will Copy it to your clipboard</p></figcaption></figure>

or you can copy it directly from the <mark style="color:blue;">REMIX IDE</mark>

<figure><img src="/files/M0C0yZgFAeR3nWLvk6cE" alt=""><figcaption><p>You can also copy through clicking this clipboard button within the REMIX IDE</p></figcaption></figure>

Click the T<mark style="color:red;">ransact button</mark> within the <mark style="color:red;">Mint Function</mark> and confirm the transaction when Metamask pops open.

***

To check the balance of your token within your wallet you will use the <mark style="color:green;">`balanceOf`</mark> Function with your wallet address as the <mark style="color:red;">parameter</mark>. You'll see the quantity of tokens that you have just created and minted into your Wallet.

<figure><img src="/files/NoH7Qrq7CUH96gA6K1Tx" alt=""><figcaption><p>balanceOf Example</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cll-devrel.gitbook.io/bootcamp-2024/3.-oracles-erc20-and-chainlink-data-feeds/create-and-deploy-erc20.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
