Skip to content

Commit 28621bb

Browse files
committed
refactor: merge section 6 into 5, renumber 7 to 6
1 parent 29deb6c commit 28621bb

File tree

76 files changed

+120
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+120
-542
lines changed

astro.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { readFileSync } from 'node:fs'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
14
import vue from '@astrojs/vue'
25
import tutorialkit from '@tutorialkit/astro'
36
import { defineConfig } from 'astro/config'
4-
import { readFileSync } from 'fs'
5-
import { fileURLToPath } from 'url'
6-
import path from 'path'
77

88
// Read package version at build time
99
const __filename = fileURLToPath(import.meta.url)

public/widget.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/widget.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/tutorial/5-polygon-basics/1-introduction/_files/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const USDC_ADDRESS = '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582'
66
const USDC_ABI = [
77
'function transfer(address to, uint256 amount) returns (bool)',
88
'function balanceOf(address account) view returns (uint256)',
9-
'function decimals() view returns (uint8)'
9+
'function decimals() view returns (uint8)',
1010
]
1111

1212
// 🔐 WALLET SETUP: Change this to your own unique password!
@@ -56,7 +56,7 @@ async function main() {
5656

5757
// Convert to 24-word mnemonic so you can import into any wallet
5858
const mnemonic = ethers.Wallet.fromMnemonic(
59-
ethers.utils.entropyToMnemonic(ethers.utils.hexZeroPad(wallet.privateKey, 32))
59+
ethers.utils.entropyToMnemonic(ethers.utils.hexZeroPad(wallet.privateKey, 32)),
6060
).mnemonic.phrase
6161
console.log('\n📝 Mnemonic (24 words):', mnemonic)
6262
console.log('💡 You can import this mnemonic into any wallet to check your balances:')
@@ -96,7 +96,7 @@ async function main() {
9696
to: RECIPIENT,
9797
value: ethers.utils.parseEther(POL_AMOUNT),
9898
maxPriorityFeePerGas,
99-
maxFeePerGas
99+
maxFeePerGas,
100100
})
101101
console.log('⏳ Transaction hash:', tx.hash)
102102

@@ -109,7 +109,8 @@ async function main() {
109109
const newPolBalance = await provider.getBalance(wallet.address)
110110
const spent = polBalance.sub(newPolBalance)
111111
console.log('📊 Total spent:', ethers.utils.formatEther(spent), 'POL (including gas)')
112-
} catch (error) {
112+
}
113+
catch (error) {
113114
console.log('❌ Failed:', error.message)
114115
}
115116

@@ -143,7 +144,7 @@ async function main() {
143144
const amountInBaseUnits = ethers.utils.parseUnits(USDC_AMOUNT, decimals)
144145
const tx = await usdc.transfer(RECIPIENT, amountInBaseUnits, {
145146
maxPriorityFeePerGas,
146-
maxFeePerGas
147+
maxFeePerGas,
147148
})
148149
console.log('⏳ Transaction hash:', tx.hash)
149150

@@ -161,7 +162,8 @@ async function main() {
161162
// Show POL used for gas (still needed for ERC20!)
162163
const finalPolBalance = await provider.getBalance(wallet.address)
163164
console.log('⛽ POL balance:', ethers.utils.formatEther(finalPolBalance), 'POL (gas paid in POL!)')
164-
} catch (error) {
165+
}
166+
catch (error) {
165167
console.log('❌ Failed:', error.message)
166168
}
167169

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"polygon-basics-demo","version":"1.0.0","type":"module","scripts":{"demo":"node --watch index.js"},"dependencies":{"ethers":"^5.7.2"}}
1+
{ "name": "polygon-basics-demo", "type": "module", "version": "1.0.0", "scripts": { "demo": "node --watch index.js" }, "dependencies": { "ethers": "^5.7.2" } }

src/content/tutorial/5-polygon-basics/1-introduction/_solution/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const USDC_ADDRESS = '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582'
66
const USDC_ABI = [
77
'function transfer(address to, uint256 amount) returns (bool)',
88
'function balanceOf(address account) view returns (uint256)',
9-
'function decimals() view returns (uint8)'
9+
'function decimals() view returns (uint8)',
1010
]
1111

1212
// 🔐 WALLET SETUP: Change this to your own unique password!
@@ -56,7 +56,7 @@ async function main() {
5656

5757
// Convert to 24-word mnemonic so you can import into any wallet
5858
const mnemonic = ethers.Wallet.fromMnemonic(
59-
ethers.utils.entropyToMnemonic(ethers.utils.hexZeroPad(wallet.privateKey, 32))
59+
ethers.utils.entropyToMnemonic(ethers.utils.hexZeroPad(wallet.privateKey, 32)),
6060
).mnemonic.phrase
6161
console.log('\n📝 Mnemonic (24 words):', mnemonic)
6262
console.log('💡 You can import this mnemonic into any wallet to check your balances:')
@@ -96,7 +96,7 @@ async function main() {
9696
to: RECIPIENT,
9797
value: ethers.utils.parseEther(POL_AMOUNT),
9898
maxPriorityFeePerGas,
99-
maxFeePerGas
99+
maxFeePerGas,
100100
})
101101
console.log('⏳ Transaction hash:', tx.hash)
102102

@@ -109,7 +109,8 @@ async function main() {
109109
const newPolBalance = await provider.getBalance(wallet.address)
110110
const spent = polBalance.sub(newPolBalance)
111111
console.log('📊 Total spent:', ethers.utils.formatEther(spent), 'POL (including gas)')
112-
} catch (error) {
112+
}
113+
catch (error) {
113114
console.log('❌ Failed:', error.message)
114115
}
115116

@@ -143,7 +144,7 @@ async function main() {
143144
const amountInBaseUnits = ethers.utils.parseUnits(USDC_AMOUNT, decimals)
144145
const tx = await usdc.transfer(RECIPIENT, amountInBaseUnits, {
145146
maxPriorityFeePerGas,
146-
maxFeePerGas
147+
maxFeePerGas,
147148
})
148149
console.log('⏳ Transaction hash:', tx.hash)
149150

@@ -161,7 +162,8 @@ async function main() {
161162
// Show POL used for gas (still needed for ERC20!)
162163
const finalPolBalance = await provider.getBalance(wallet.address)
163164
console.log('⛽ POL balance:', ethers.utils.formatEther(finalPolBalance), 'POL (gas paid in POL!)')
164-
} catch (error) {
165+
}
166+
catch (error) {
165167
console.log('❌ Failed:', error.message)
166168
}
167169

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"polygon-basics-demo","version":"1.0.0","type":"module","scripts":{"demo":"node --watch index.js"},"dependencies":{"ethers":"^5.7.2"}}
1+
{ "name": "polygon-basics-demo", "type": "module", "version": "1.0.0", "scripts": { "demo": "node --watch index.js" }, "dependencies": { "ethers": "^5.7.2" } }

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Welcome to Polygon Basics! Over the next three lessons you will assemble a compl
2020
## Why Polygon?
2121

2222
**Polygon** is an Ethereum Layer 2 network designed to feel familiar while solving Ethereum's biggest pain points.
23+
2324
- **Same developer experience**: It speaks the Ethereum Virtual Machine (EVM), so tools like ethers.js, Hardhat, or MetaMask work without modification.
2425
- **Lower transaction costs**: Fees are measured in fractions of a cent instead of whole dollars.
2526
- **Faster confirmations**: Blocks land roughly every two seconds, keeping interactions snappy.
@@ -33,10 +34,10 @@ Think of Polygon as Ethereum's faster, more affordable sibling that still shares
3334

3435
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.
3536

36-
- **Network Name**: Polygon Amoy Testnet
37-
- **Chain ID**: 80002
38-
- **RPC URL**: https://rpc-amoy.polygon.technology
39-
- **Block Explorer**: https://amoy.polygonscan.com
37+
- **Network Name**: Polygon Amoy Testnet
38+
- **Chain ID**: 80002
39+
- **RPC URL**: https://rpc-amoy.polygon.technology
40+
- **Block Explorer**: https://amoy.polygonscan.com
4041
- **Native Token**: POL (pays gas fees)
4142

4243
Because every token on Amoy is free, you can try ideas, make mistakes, and rerun scripts without worrying about real money.
@@ -48,17 +49,20 @@ Because every token on Amoy is free, you can try ideas, make mistakes, and rerun
4849
By the end of this part you will have a working toolkit for everyday Polygon development:
4950

5051
### Lesson 2: Polygon Wallet Setup & Faucets
52+
5153
- Generate an Ethereum-compatible wallet with ethers.js.
5254
- Connect that wallet to Polygon Amoy.
5355
- Collect free POL and USDC from public faucets.
5456
- Read balances programmatically so you can verify funding.
5557

5658
### Lesson 3: Sending POL Transactions
59+
5760
- Craft and broadcast native POL transfers.
5861
- Inspect gas usage and confirmation receipts.
5962
- Follow the transaction lifecycle on PolygonScan.
6063

6164
### Lesson 4: ERC20 Tokens & USDC Transfers
65+
6266
- Review the ERC20 interface and why it matters.
6367
- Interact with token contracts through ABIs.
6468
- Send USDC and account for its six decimal places.
@@ -70,6 +74,7 @@ Each lesson builds on the previous one, so keep your project files handy as you
7074
## Why These Skills Matter
7175

7276
Mastering Polygon translates directly to the broader EVM ecosystem:
77+
7378
- Mainnet Ethereum and Layer 2 networks such as Optimism, Arbitrum, and Base share the same patterns.
7479
- Sidechains like BNB Chain or Avalanche use identical wallet and contract workflows.
7580
- Any project that relies on ethers.js or web3.js expects these fundamentals.
@@ -81,11 +86,13 @@ Once you are comfortable on Polygon, you can approach most EVM-based platforms w
8186
## The Demo Script
8287

8388
The code bundled with this lesson is a complete end-to-end walkthrough of everything you will build in Lessons 2-4. The demo runs automatically when you open this lesson—just check the terminal output. Treat it as a living reference:
89+
8490
- **Review the terminal** to see the final experience in action.
8591
- **Copy individual snippets** as you implement each step in the subsequent lessons.
8692
- **Compare your work** against the finished version if you get stuck.
8793

8894
The script demonstrates how to:
95+
8996
1. Create a wallet and connect to Polygon Amoy.
9097
2. Check POL and USDC balances.
9198
3. Send POL to another address.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"polygon-wallet-setup","version":"1.0.0","type":"module","scripts":{"dev":"node --watch index.js"},"dependencies":{"ethers":"^5.7.2"}}
1+
{ "name": "polygon-wallet-setup", "type": "module", "version": "1.0.0", "scripts": { "dev": "node --watch index.js" }, "dependencies": { "ethers": "^5.7.2" } }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"polygon-wallet-setup","version":"1.0.0","type":"module","scripts":{"dev":"node --watch index.js"},"dependencies":{"ethers":"^5.7.2"}}
1+
{ "name": "polygon-wallet-setup", "type": "module", "version": "1.0.0", "scripts": { "dev": "node --watch index.js" }, "dependencies": { "ethers": "^5.7.2" } }

0 commit comments

Comments
 (0)