Skip to content

Commit 862b747

Browse files
committed
docs: review polygon basics & gasless lessons
1 parent ab1884a commit 862b747

11 files changed

Lines changed: 202 additions & 74 deletions

File tree

src/content/tutorial/5-polygon-basics/1-introduction/content.md

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,43 @@ terminal:
1313

1414
# Introduction to Polygon
1515

16+
Before starting this section, you should have:
17+
18+
- Completed Sections 1–4 of this tutorial
19+
- Basic understanding of EVM wallets and blockchain transactions
20+
- MetaMask or similar wallet extension installed
21+
22+
## Learning Objectives
23+
24+
By the end of this section, you will be able to:
25+
26+
- Set up and connect a wallet to the Polygon network (testnet and mainnet)
27+
- Distinguish between native POL tokens and ERC-20 tokens like USDC
28+
- Interact with ERC-20 token contracts on Polygon
29+
- Send USDC transactions on Polygon testnet
30+
- Verify transactions on Polygonscan block explorer
31+
32+
---
33+
1634
Welcome to Polygon Basics! Over the next three lessons you will assemble a complete transaction workflow on Polygon: create wallets, fund them with test assets, and move both native POL and ERC20 tokens. Each lesson flows step by step so you can focus on the concepts rather than deciphering shorthand.
1735

36+
The Nimiq Wallet supports stablecoins on EVM chains. The concepts you learn here (wallets, providers, POL gas, ERC20) are the foundation for Part 6 where we implement Nimiq‑style gasless transfers with OpenGSN.
37+
1838
---
1939

40+
> **Prerequisites & Safety**
41+
>
42+
> - Use a fresh test wallet. Don't reuse mainnet or exchange keys.
43+
> - You will add a `PRIVATE_KEY` in a `.env` file in Lesson 2; no setup is needed yet.
44+
> - Faucets provide the test tokens you will need later; nothing to do in this introduction.
45+
46+
> **Terminology**
47+
>
48+
> - **POL**: Polygon's native token (formerly MATIC). Gas is paid in POL.
49+
> - **EVM**: Ethereum Virtual Machine; the execution environment used by Polygon.
50+
> - **ERC20**: Token standard for fungible tokens (for example, USDC has 6 decimals).
51+
> - **Provider**: An RPC endpoint your code connects to (for example, `https://rpc-amoy.polygon.technology`).
52+
2053
## Why Polygon?
2154

2255
**Polygon** is an Ethereum Layer 2 network designed to feel familiar while solving Ethereum's biggest pain points.
@@ -28,40 +61,50 @@ Welcome to Polygon Basics! Over the next three lessons you will assemble a compl
2861

2962
Think of Polygon as Ethereum's faster, more affordable sibling that still shares the family DNA.
3063

64+
### Note on Polygon's Native Token
65+
66+
Polygon's native token was rebranded from **MATIC** to **POL** in 2024.
67+
68+
- **On Polygon mainnet:** Use POL (contract not applicable; native asset)
69+
- **On Polygon testnet (Amoy):** Use test POL from the faucet
70+
- **In code references:** You may see both names in older documentation; they refer to the same asset
71+
72+
This tutorial uses **POL** throughout.
73+
3174
---
3275

3376
## Meet Polygon Amoy
3477

35-
For this section we use **Polygon Amoy**, the current Polygon testnet. It mirrors mainnet behavior while using valueless tokens, which makes it ideal for experimentation.
78+
For this section we use **Polygon Amoy**, the current Polygon testnet. It mirrors mainnet behavior with valueless test tokens, which makes it ideal for experimentation.
3679

3780
- **Network Name**: Polygon Amoy Testnet
3881
- **Chain ID**: 80002
3982
- **RPC URL**: https://rpc-amoy.polygon.technology
4083
- **Block Explorer**: https://amoy.polygonscan.com
4184
- **Native Token**: POL (pays gas fees)
4285

43-
Because every token on Amoy is free, you can try ideas, make mistakes, and rerun scripts without worrying about real money.
86+
Because test tokens on Amoy are free, you can try ideas, make mistakes, and rerun scripts without worrying about real money.
4487

4588
---
4689

4790
## What You Will Build
4891

49-
By the end of this part you will have a working toolkit for everyday Polygon development:
92+
By the end of this part, you will have a working toolkit for everyday Polygon development:
5093

51-
### Lesson 2: Polygon Wallet Setup & Faucets
94+
### Polygon Wallet Setup & Faucets
5295

5396
- Generate an Ethereum-compatible wallet with ethers.js.
5497
- Connect that wallet to Polygon Amoy.
5598
- Collect free POL and USDC from public faucets.
5699
- Read balances programmatically so you can verify funding.
57100

58-
### Lesson 3: Sending POL Transactions
101+
### Sending POL Transactions
59102

60103
- Craft and broadcast native POL transfers.
61104
- Inspect gas usage and confirmation receipts.
62105
- Follow the transaction lifecycle on PolygonScan.
63106

64-
### Lesson 4: ERC20 Tokens & USDC Transfers
107+
### ERC20 Tokens & USDC Transfers
65108

66109
- Review the ERC20 interface and why it matters.
67110
- Interact with token contracts through ABIs.
@@ -98,10 +141,17 @@ The script demonstrates how to:
98141
3. Send POL to another address.
99142
4. Transfer USDC (an ERC20 token) safely.
100143

101-
> 💡 **Heads-up**: You will still need faucet funds before the demo shows non-zero balances. Lesson 2 covers that process. Until then you will see warnings about missing tokens.
144+
> 💡 **Heads-up**: You will still need faucet funds before the demo shows non-zero balances. Lesson 2 covers that process. Until then, you will see warnings about missing tokens.
145+
146+
## What the Demo Shows
147+
148+
- The terminal prints a wallet address and environment details.
149+
- Balances start at zero until you use faucets in Lesson 2.
150+
- You will see warnings about missing tokens; they are expected.
151+
- The editor opens `/index.js`. Feel free to skim it; you do not need to change anything in this lesson.
102152

103153
---
104154

105155
## Next Up
106156

107-
Continue to **Lesson 2: Polygon Wallet Setup & Faucets** to create your first Polygon wallet and stock it with testnet tokens.
157+
Continue to **Polygon Wallet Setup & Faucets** to create your first Polygon wallet and stock it with testnet tokens.

src/content/tutorial/5-polygon-basics/2-wallet-and-faucets/content.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ By the end of this lesson you will:
2424
- **Generate an Ethereum-compatible wallet** with ethers.js and understand the difference between its private key and public address.
2525
- **Connect the wallet to Polygon Amoy**, Polygon's public testnet.
2626
- **Collect free POL** to pay for gas in upcoming lessons.
27-
- **Collect free USDC** so you can practice ERC20 transfers later on.
27+
- **Collect free USDC** so you can practice ERC20 transfers later.
2828
- **Store sensitive credentials safely** using environment variables.
2929

3030
---
@@ -38,7 +38,7 @@ Wallets sit at the heart of every Web3 interaction. Whether you are experimentin
3838
- Verify balances before submitting transactions.
3939
- Reuse credentials across scripts without exposing them.
4040

41-
Master these fundamentals now and everything that follows will feel natural.
41+
Master these fundamentals now, and everything that follows will feel natural.
4242

4343
---
4444

@@ -51,7 +51,7 @@ We will work on **Polygon Amoy**, a no-stakes environment that mirrors Polygon m
5151
- **RPC URL**: https://rpc-amoy.polygon.technology
5252
- **Chain ID**: 80002
5353

54-
Because tokens on Amoy have zero real-world value, you can experiment freely and rerun scripts as often as you like.
54+
Because test tokens on Amoy have zero real-world value, you can experiment freely and rerun scripts as often as you like.
5555

5656
---
5757

@@ -107,11 +107,15 @@ You should see `0.0 POL`, confirming the wallet has not been funded yet.
107107
Faucets distribute play tokens for testnets. Follow these steps to fund your wallet with POL:
108108

109109
1. Copy the address printed in your console.
110-
2. Visit the Polygon faucet at **https://faucet.polygon.technology/**.
110+
2. Visit the Polygon faucet at https://faucet.polygon.technology/.
111111
3. Choose "Polygon Amoy" from the dropdown.
112112
4. Paste your address and submit the request.
113113

114-
Within roughly 30 seconds the faucet should confirm the transfer. Run your script again to verify that the POL balance increased.
114+
Within roughly 30 seconds, the faucet should confirm the transfer. Run your script again to verify that the POL balance increased. You can also check your address on the explorer: https://amoy.polygonscan.com/address/<your-address>
115+
116+
> Faucet tips
117+
>
118+
> If the faucet rate-limits you, wait a few minutes and retry. Make sure “Polygon Amoy” is selected. Some public faucets require sign-in or a CAPTCHA.
115119
116120
---
117121

@@ -121,19 +125,23 @@ Later lessons rely on an ERC20 token, so grab some USDC while you are here. You
121125

122126
**Option 1: Polygon Faucet** (also gives POL)
123127

124-
1. Visit **https://faucet.polygon.technology/**.
128+
1. Visit https://faucet.polygon.technology/.
125129
2. Choose "Polygon Amoy" from the dropdown.
126130
3. Paste your wallet address and submit.
127131

128132
**Option 2: Circle Faucet**
129133

130-
1. Open **https://faucet.circle.com/**.
134+
1. Open https://faucet.circle.com/.
131135
2. Select "Polygon Amoy" as the network.
132136
3. Paste your wallet address.
133137
4. Complete the CAPTCHA and submit.
134138

135139
To inspect your USDC balance you must query the token contract directly:
136140

141+
> Note on test tokens
142+
>
143+
> USDC testnet addresses can change. If the address returns zero unexpectedly, verify the current Amoy USDC address from official sources (faucet/docs) before assuming a code issue.
144+
137145
```js
138146
const USDC_ADDRESS = '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582'
139147
const USDC_ABI = [
@@ -181,4 +189,4 @@ You now have everything required for real Polygon workflows:
181189
- ✅ USDC for ERC20 experiments.
182190
- ✅ Environment variable management for safe credential storage.
183191

184-
In the next lesson you will send your first on-chain POL transfer and watch it confirm in real time.
192+
In the next lesson, you will send your first on-chain POL transfer and watch it confirm in real time.

src/content/tutorial/5-polygon-basics/3-sending-pol/content.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ With your wallet funded, it is time to perform a live transaction on Polygon Amo
2727

2828
Keep a small buffer of POL in your wallet; even ERC20 transfers consume it for gas.
2929

30-
> 💡 **Nimiq contrast:** Nimiq blockchain has zero transaction fees. No gas token, no fee calculations—just send. We'll revisit this advantage in Section 6 when we tackle gasless transactions!
30+
> 💡 **Nimiq contrast:** Nimiq blockchain has zero transaction fees. No gas token, no fee calculations—just send. We will revisit this advantage in Section 6 when we tackle gasless transactions!
3131
3232
---
3333

@@ -149,7 +149,7 @@ Gas Fee = Gas Used × Gas Price
149149
- **Gas Used** represents the work done (a simple transfer is roughly 21,000 units).
150150
- **Gas Price** fluctuates with network demand.
151151

152-
On Polygon Amoy these fees are tiny, but cultivating the habit of checking them now will pay off on higher-cost networks.
152+
On Polygon Amoy, these fees are tiny, but cultivating the habit of checking them now will pay off on higher-cost networks.
153153

154154
---
155155

src/content/tutorial/5-polygon-basics/4-erc20-usdc/content.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ terminal:
1313

1414
# ERC20 Tokens & USDC Transfers
1515

16-
# ERC20 Tokens & USDC Transfers
17-
18-
Native POL transfers are only half the story on Polygon. The majority of assets you will handle live inside smart contracts that follow the ERC20 standard. In this lesson you will apply everything you learned about wallets and providers to interact with **USDC**, a widely used stablecoin on Polygon Amoy.
16+
Native POL transfers are only half the story on Polygon. The majority of assets you will handle live inside smart contracts that follow the ERC20 standard. In this lesson, you will apply everything you learned about wallets and providers to interact with **USDC**, a widely used stablecoin on Polygon Amoy.
1917

2018
---
2119

@@ -133,7 +131,7 @@ Key differences from the POL workflow:
133131

134132
## Step 5: Reconcile Balances
135133

136-
After confirmation, confirm that both your USDC and POL balances changed as expected.
134+
After confirmation, check that both your USDC and POL balances have changed as expected.
137135

138136
```js
139137
const newBalance = await usdc.balanceOf(wallet.address)
@@ -150,8 +148,8 @@ console.log('\n⛽ Gas paid in POL:', ethers.utils.formatEther(polBalance))
150148

151149
You should see:
152150

153-
- Your USDC balance drop by the transfer amount.
154-
- Your POL balance dip slightly from gas costs.
151+
- Your USDC balance drops by the transfer amount.
152+
- Your POL balance dips slightly from gas costs.
155153
- The recipient's USDC balance increases accordingly.
156154

157155
---
@@ -163,7 +161,7 @@ ERC20 transfers invoke smart contract logic, so they use more gas than native tr
163161
- Native POL transfer: about 21,000 gas.
164162
- ERC20 transfer: typically 50,000 to 65,000 gas.
165163

166-
Polygon's low fees mean the difference is small, but it is important to keep in mind on higher-cost networks.
164+
Polygons low fees mean the difference is small, but it is important to keep in mind on higher-cost networks.
167165

168166
---
169167

src/content/tutorial/6-gasless-transfers/1-wallet-setup/content.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ terminal:
1313

1414
# Mainnet Wallet Setup
1515

16-
Before working with gasless transactions on Polygon mainnet, you need a wallet with real funds. This lesson generates a fresh wallet and shows you how to secure it properly.
16+
Before working with gasless transactions on Polygon mainnet, you need a wallet with real funds. This lesson generates a new wallet and shows you how to secure it properly.
1717

1818
---
1919

@@ -67,7 +67,7 @@ console.log('Mnemonic:', wallet.mnemonic.phrase)
6767

6868
For a better UX, import your 24-word mnemonic into the Nimiq Wallet:
6969

70-
1. Visit **https://wallet.nimiq.com**
70+
1. Visit https://wallet.nimiq.com
7171
2. Select "Import with Recovery Words"
7272
3. Paste your 24-word phrase
7373
4. Access your wallet through a friendly interface
@@ -78,37 +78,55 @@ The Nimiq Wallet supports Polygon and makes managing tokens easier than the comm
7878

7979
## Get Mainnet Funds
8080

81-
You need two types of tokens:
81+
### USDT (for core gasless transfers)
8282

83-
### USDC (for transfers)
83+
You will use USDT for the baseline and OpenGSN lessons (Lessons 3–6). There is no public faucet for USDT on Polygon mainnet, so you must:
8484

85-
Visit **https://faucet.circle.com/** to get testnet USDC that works on mainnet. You will need 2-5 USDC to complete the gasless lessons.
85+
- Purchase USDT on an exchange and withdraw to Polygon
86+
- Swap into USDT on Polygon using a DEX such as Uniswap
87+
- Bridge USDT from Ethereum mainnet
8688

87-
### POL (for gas in Lesson 2)
89+
Aim for 2–5 USDT to comfortably complete the exercises.
8890

89-
Visit **https://faucet.polygon.technology/** to get a small amount of POL. You only need ~0.1 POL for the baseline gasful transaction in the next lesson.
91+
### USDC (for the permit lesson)
9092

91-
### USDT (no faucet available)
93+
USDC is only needed for the EIP-2612 permit lesson (Lesson 7). For Polygon mainnet USDC you must use a real liquidity source. Typical options are:
9294

93-
There is no public faucet for USDT on Polygon mainnet. If you want to follow along with USDT examples instead of USDC, you will need to:
95+
- Purchase USDC on an exchange and withdraw directly to Polygon
96+
- Bridge USDC from another chain (for example Ethereum mainnet) using a trusted bridge
97+
- Swap into USDC on Polygon via a DEX such as Uniswap
9498

95-
- Purchase USDT on an exchange and withdraw to Polygon
96-
- Swap USDC for USDT using a DEX like Uniswap
97-
- Bridge USDT from Ethereum mainnet
99+
If you want to practice on testnets before touching mainnet, you can use https://faucet.circle.com/ to obtain **testnet** USDC on supported networks. That testnet USDC is not usable on Polygon mainnet.
100+
101+
### POL (for gas in gasful baseline lesson)
102+
103+
For Polygon mainnet POL you cannot use the Polygon faucet (it only serves testnets like Amoy). Instead:
98104

99-
> For this tutorial, USDC is recommended since it has faucet access.
105+
- Acquire POL on an exchange and withdraw to Polygon mainnet, or
106+
- Bridge POL (or wrapped MATIC) from another network.
107+
108+
You only need ~0.1 POL for the baseline gasful transaction in the next lesson, but it must be real mainnet POL.
100109

101110
---
102111

103112
## Save Your Private Key
104113

105-
Copy your **private key** from the terminal output. You will paste it directly into the code files in the following lessons. Each lesson will have a placeholder like:
114+
Copy your **private key** from the terminal output. In the following lessons, load it from an environment variable instead of hardcoding it in source code. For example:
115+
116+
```bash
117+
# .env
118+
SENDER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_FROM_LESSON_1
119+
```
106120

107121
```js
108-
const PRIVATE_KEY = '0xPASTE_YOUR_PRIVATE_KEY_HERE_FROM_LESSON_1'
122+
import dotenv from 'dotenv'
123+
124+
dotenv.config()
125+
126+
const wallet = new ethers.Wallet(process.env.SENDER_PRIVATE_KEY, provider)
109127
```
110128

111-
Replace that placeholder with your actual private key. Never commit files with your real private key to version control.
129+
Never commit `.env` files with real private keys to version control.
112130

113131
---
114132

@@ -124,4 +142,4 @@ Before moving forward, confirm:
124142

125143
## Next Up
126144

127-
In **Lesson 2: Introduction to Gasless Transactions**, you will learn why gasless transactions matter and see the architecture that makes them possible.
145+
In **Introduction to Gasless Transactions**, you will learn why gasless transactions matter and see the architecture that makes them possible.

0 commit comments

Comments
 (0)