Skip to content

Commit

Permalink
Add L1 Tokenomics Course (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
owenwahlgren authored Oct 1, 2024
2 parents 43027bc + c3c6b58 commit ae3a2ab
Show file tree
Hide file tree
Showing 49 changed files with 1,603 additions and 7 deletions.
Binary file added app/backup.ico
Binary file not shown.
Binary file modified app/favicon.ico
Binary file not shown.
58 changes: 56 additions & 2 deletions app/layout.client.tsx

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions components/quizzes/courses/l1-tokenomics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"201": {
"question": "Which function is used to allow another account to transfer tokens on your behalf?",
"options": [
"transfer()",
"approve()",
"transferFrom()",
"allowance()"
],
"correctAnswers": [
1
],
"hint": "This function sets an approval limit for token transfers by a third party.",
"explanation": "The approve() function allows another account to spend tokens on your behalf up to a specified amount.",
"chapter": "ERC-20 Tokens"
},
"202": {
"question": "What is the primary purpose of wrapping a native token into an ERC-20 token?",
"options": [
"To increase its supply",
"To burn the native token",
"To make the native token compatible with the ERC-20 standard",
"To mint more native tokens"
],
"correctAnswers": [
2
],
"hint": "Wrapping allows the native token to be used in decentralized applications that require ERC-20 tokens.",
"explanation": "The wrapping process makes native tokens (like ETH, AVAX) compatible with the ERC-20 standard, enabling their use in dApps and DeFi protocols.",
"chapter": "Wrapped Native Tokens"
},
"203": {
"question": "What is the primary advantage of using a custom native token in a blockchain?",
"options": [
"It automatically increases in value over time",
"It can only be used for test environments",
"It eliminates the need for validators",
"It allows for more control over transaction fees and tokenomics"
],
"correctAnswers": [
3
],
"hint": "Custom native tokens give developers flexibility in managing blockchain economics.",
"explanation": "A custom native token allows developers to control transaction fees, design tokenomics, and tailor the blockchain’s fee structure to meet specific needs.",
"chapter": "Custom Native Tokens"
},
"204": {
"question": "What is the AllowList used for when configuring the Native Minter Precompile?",
"options": [
"To set transaction fees for using the native token",
"To control which addresses are allowed to mint native tokens",
"To limit the total number of native tokens that can be minted",
"To freeze minting of native tokens"
],
"correctAnswers": [
1
],
"hint": "The allow list determines which addresses have permission to interact with the precompiled contract.",
"explanation": "The AllowList is used to specify which addresses have the permission to mint native tokens or manage the minting process.",
"chapter": "Activating Native Minter Precompile"
},
"205": {
"question": "What is the main advantage of a multi-chain ecosystem?",
"options": [
"It reduces the security of the blockchain.",
"It increases the gas fees.",
"It enables tokens and assets to be transferred across multiple blockchains.",
"It restricts interoperability between different blockchains."
],
"correctAnswers": [
2
],
"hint": "Think about the ability of assets and tokens to move freely across multiple chains.",
"explanation": "The key benefit of a multi-chain ecosystem is that it allows tokens, assets, and data to be transferred between different blockchains, promoting interoperability.",
"chapter": "Cross-Chain Ecosystems"
},
"206": {
"question": "What role does Avalanche play in enabling multi-chain ecosystems?",
"options": [
"It provides a single-chain environment for transactions.",
"It limits token usage to the native chain.",
"It supports seamless cross-chain communication with tools like L1s and ICTT.",
"It prevents interoperability between its L1s and other chains."
],
"correctAnswers": [
2
],
"hint": "Avalanche is known for its ability to support cross-chain communication and interoperability through its architecture.",
"explanation": "Avalanche's architecture, including its L1s and Interchain Token Transfers (ICTT), is designed to support seamless cross-chain communication and interoperability between different blockchain networks.",
"chapter": "Cross-Chain Ecosystems"
},
"207": {
"question": "Which contract must be granted minting rights for the ERC-20 token to be used as a native token on a new L1 chain?",
"options": [
"NativeTokenRemote contract",
"ERC-20 Home contract",
"ERC-712 contract",
"L1 governance contract"
],
"correctAnswers": [
0
],
"hint": "This contract mints native tokens on the destination chain after ERC-20 tokens are transferred.",
"explanation": "The NativeTokenRemote contract must be granted minting rights to allow the native token to be minted on the new L1 after ERC-20 tokens are transferred from the source chain.",
"chapter": "Use ERC-20 as Native Token"
},
"208": {
"question": "Why is collateralization important in transferring native tokens between L1 chains?",
"options": [
"It increases the supply of tokens on the C-Chain.",
"It ensures the total supply of tokens remains balanced across both chains.",
"It burns the tokens on the remote chain.",
"It locks the token permanently on the C-Chain."
],
"correctAnswers": [
1
],
"hint": "Collateralization ensures balance across chains during token transfers.",
"explanation": "Collateralization locks the transferred tokens on the source chain, ensuring that the minted tokens on the destination chain have an equivalent backing.",
"chapter": "Use ERC-20 as Native Token"
},
"209": {
"question": "What is the purpose of wrapping a native token on the C-Chain before transferring it to a new L1?",
"options": [
"To convert it into an ERC-721 token.",
"To prepare it for cross-chain transfer as an ERC-20 token.",
"To lock it in a smart contract and mint its representation on the new L1.",
"To burn the token and reduce its total supply."
],
"correctAnswers": [
2
],
"hint": "Wrapping a token creates a compatible version of it for cross-chain transfers.",
"explanation": "Wrapping the native token locks it on the C-Chain, allowing a compatible version of the token to be minted on the new L1, ensuring the cross-chain token transfer process.",
"chapter": "Use ERC-20 as Native Token"
}
}
7 changes: 6 additions & 1 deletion components/quizzes/quiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Image from 'next/image';
import { cn } from '@/utils/cn';
import { buttonVariants } from '@/components/ui/button';
import quizData from './quizData.json';
import l1TokenomicsQuestions from './courses/l1-tokenomics.json';

interface QuizProps {
quizId: string;
Expand All @@ -28,7 +29,11 @@ const Quiz: React.FC<QuizProps> = ({ quizId }) => {

useEffect(() => {
setIsClient(true);
const fetchedQuizInfo = quizData.quizzes[quizId as keyof typeof quizData.quizzes];
const all = {
...quizData.quizzes,
...l1TokenomicsQuestions
};
const fetchedQuizInfo = all[quizId as keyof typeof quizData.quizzes];
if (fetchedQuizInfo) {
setQuizInfo(fetchedQuizInfo);
}
Expand Down
4 changes: 4 additions & 0 deletions components/quizzes/quizData.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"avalanche-fundamentals": {
"title": "Avalanche Fundamentals",
"quizzes": ["101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117"]
},
"l1-tokenomics": {
"title": "L1 Tokenomics",
"quizzes": ["201", "202", "203", "204", "205", "206", "207", "208", "209"]
}
},
"quizzes": {
Expand Down
8 changes: 8 additions & 0 deletions content/common/intro/instructors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ const instructors: Instructor[] = [
twitter: "https://x.com/owenwahlgren",
linkedin: "https://www.linkedin.com/in/owenwahlgren/",
github: "https://github.com/owenwahlgren",
},
{
name: "Sarp",
title: "Sr. Developer Relations Engineer",

twitter: "https://x.com/satatocom",
linkedin: "https://www.linkedin.com/in/sarptaylan/",
github: "https://github.com/0xstt",
}
];

Expand Down
29 changes: 29 additions & 0 deletions content/course/l1-tokenomics/01-basics/01-native-tokens.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Native Tokens
description: Learn about native tokens and their role in blockchain ecosystems.
updated: 2024-09-03
authors: [0xstt]
icon: Book
---

A **native token** in a blockchain running the Ethereum Virtual Machine (EVM) refers to the primary digital currency or cryptocurrency native to that blockchain. Native tokens act as the foundation for value transfer and network operation within their respective ecosystems.

- **Ethereum**: ETH
- **Avalanche C-Chain**: AVAX
- **Dexalot**: ALOT
- many more...

---

### The Role of Native Tokens

Native tokens serve multiple key roles within EVM-based blockchain networks, such as:

- **Value Transfer**: Native tokens act as the primary currency for peer-to-peer transactions within the network, enabling value exchange between participants.
- **Gas Fees**: Native tokens are used as **gas** to pay for transaction fees, contract deployments, and other network operations. This ensures that resources are allocated efficiently within the network.
- **Security**: In Proof-of-Stake (PoS) networks, native tokens are often used for staking to secure the network and validate transactions.
- **Governance**: In some cases, native tokens grant holders governance rights, allowing them to participate in decision-making processes that shape the blockchain’s future.

---

Native tokens are the backbone of blockchain ecosystems, serving multiple roles that maintain the network's stability, security, and functionality.
98 changes: 98 additions & 0 deletions content/course/l1-tokenomics/01-basics/02-erc-20-tokens.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: ERC-20 Tokens
description: Learn about ERC-20 tokens and their role in blockchain ecosystems.
updated: 2024-09-03
authors: [0xstt]
icon: Book
---

While a blockchain has a single **native token**, the **ERC-20** token standard was developed to allow for the representation of a wide range of assets on EVM-compatible chains.

**ERC** stands for **Ethereum Request for Comment**, and **20** is the identifier for the specific proposal that defines the standard.

ERC-20 tokens are **fungible**, meaning each token is identical to another and can be exchanged on a one-to-one basis. These tokens are created and managed through smart contracts that adhere to the ERC-20 standard, ensuring interoperability between different tokens and decentralized applications (DApps).

---

### ERC-20 Token Architecture

At the core of every ERC-20 token is a simple **mapping** of addresses to balances, representing the number of tokens an address holds.

```solidity
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
//...
}
```

Addresses holding ERC-20 tokens can belong to either **Externally Owned Accounts (EOAs)** or **smart contracts**. Both types of accounts can store and transfer ERC-20 tokens, making ERC-20 tokens versatile in decentralized finance (DeFi) and decentralized applications.

---

### Role of ERC-20 Tokens in Blockchain Ecosystems

ERC-20 tokens play an essential role in enabling the creation of decentralized applications with various functionalities:

- **Tokenized Assets**: ERC-20 tokens can represent anything from digital currencies to tokenized real-world assets.
- **DeFi Protocols**: Many DeFi protocols use ERC-20 tokens for lending, staking, and liquidity pools.
- **Token Sales**: ICOs (Initial Coin Offerings) and other fundraising models rely heavily on ERC-20 tokens.

---

### The ERC-20 Interface

All ERC-20 tokens follow a standard interface to ensure compatibility with decentralized applications (DApps). This allows tokens to be easily transferred, approved for spending, and managed by any DApp that follows the same rules.

```solidity
interface IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256 balance);
function transfer(address _to, uint256 _value) external returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) external returns (bool success);
function allowance(address _owner, address _spender) external view returns (uint256 remaining);
}
```

You can review the full **ERC-20 standard** [here](https://eips.ethereum.org/EIPS/eip-20).

---

### Transferring ERC-20 Tokens

To transfer ERC-20 tokens between accounts, you use the `transfer()` function, where the sender specifies the recipient’s address and the amount to be transferred.

For more complex interactions, such as allowing a smart contract to transfer tokens on behalf of someone else, the ERC-20 standard includes the `approve()` and `transferFrom()` functions.


<Accordions>
<Accordion title="transfer()">
Transfers tokens from the sender’s account to another account, decreasing the sender's balance and increasing the recipient’s.
</Accordion>
<Accordion title="approve()">
This function allows the owner of a token balance to approve another account (the **spender**) to withdraw up to a specified amount of tokens. The spender can withdraw from the owner's balance multiple times, as long as the total amount doesn’t exceed the approved limit.
</Accordion>
<Accordion title="allowance()">
The `allowance()` function returns the amount that a spender is still allowed to withdraw from an owner's balance.
</Accordion>
<Accordion title="transferFrom()">
This function facilitates the transfer of tokens from one account to another on behalf of the account owner. It is typically used in scenarios where smart contracts need to execute token transfers according to the contract's logic.
</Accordion>
</Accordions>

---

ERC-20 tokens revolutionized the blockchain space by enabling the tokenization of assets and simplifying the creation of decentralized applications. Their standardization ensures compatibility across platforms and DApps, making them an integral part of the broader crypto ecosystem.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Deploy and Transfer an ERC-20 Token
description: Learn how to deploy an ERC-20 token and transfer it between accounts.
updated: 2024-09-03
authors: [0xstt]
icon: Terminal
---

In this section, you will follow a step-by-step guide to deploy an ERC-20 token on a blockchain network and transfer it between accounts. This will provide practical experience with token creation, deployment, and handling transactions.

### Objectives:
- Deploy an ERC-20 token smart contract.
- Interact with your token by transferring it between different accounts.

To learn how to deploy an ERC-20 token and interact with your token on a blockchain, follow [this guide](/course/interchain-token-transfer/03-tokens/08-transfer-an-erc-20-token) to explore the deployment process using the CLI on our Avalanche L1.

<Quiz quizId="201"/>
56 changes: 56 additions & 0 deletions content/course/l1-tokenomics/01-basics/04-wrapped-tokens.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Wrapped Native Tokens
description: Learn about wrapped tokens and their role in blockchain ecosystems.
updated: 2024-09-03
authors: [0xstt]
icon: Book
---

**Wrapped tokens** are blockchain assets that represent a native cryptocurrency (e.g., AVAX, ALOT, ETH) in a tokenized form, typically conforming to the **ERC-20 token standard**. Wrapping a native token allows it to be used in decentralized applications (dApps) and protocols that require ERC-20 tokens.

---

### What Are Wrapped Tokens?

Wrapped tokens are created through a process where the native cryptocurrency is locked in a smart contract, and an equivalent amount of the wrapped token is minted. These wrapped tokens are backed 1:1 by the underlying native asset, ensuring that the value of the wrapped token mirrors that of the original native cryptocurrency.

This **ERC-20 compatibility** is crucial for enabling the native asset to interact with dApps, decentralized exchanges (DEXs), and smart contracts within the EVM ecosystem, where ERC-20 tokens are the standard.

---

### Why Are Wrapped Tokens Important?

Wrapped tokens play an essential role in **interoperability** within the EVM ecosystem, facilitating seamless use across decentralized applications and protocols. Some key benefits include:

- **Liquidity**: Wrapped tokens increase liquidity in DeFi by enabling users to participate in protocols that require ERC-20 tokens, even when their original asset is a native token.
- **Cross-Chain Compatibility**: Wrapped tokens allow assets from one blockchain (e.g., Bitcoin) to be used on another chain, enhancing cross-chain functionality.
- **DeFi Integration**: Wrapped tokens are vital in DeFi protocols such as lending, borrowing, staking, and liquidity pools, where ERC-20 tokens are the standard.

---

### Wrapped Token Contract Interface

A **wrapped token contract** is typically an implementation of the ERC-20 token standard, with added functions for minting and burning tokens to facilitate the wrapping and unwrapping process. Here's a basic contract interface for a wrapped token:

```solidity
interface IWrappedToken {
function deposit() external payable;
function withdraw(uint256 amount) external;
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
```

<Accordions>
<Accordion title="deposit()">
This function is used to wrap native tokens. When a user calls deposit(), they send the native cryptocurrency (e.g., AVAX, ETH) to the contract, which then mints an equivalent amount of the wrapped token.
</Accordion>
<Accordion title="withdraw()">
This function is used to unwrap the tokens. It burns the specified amount of wrapped tokens and returns the equivalent amount of native cryptocurrency to the user.
</Accordion>
</Accordions>
Loading

0 comments on commit ae3a2ab

Please sign in to comment.