Skip to content

Commit d09edd8

Browse files
committed
fix: remove process.exit(1) from error handlers
1 parent 247c45e commit d09edd8

File tree

35 files changed

+532
-488
lines changed

35 files changed

+532
-488
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"type": "module",
3-
"scripts": {"generate": "node --watch index.js"},
4-
"dependencies": {"ethers": "^5.7.2"}
3+
"scripts": { "generate": "node --watch index.js" },
4+
"dependencies": { "ethers": "^5.7.2" }
55
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"type": "module",
3-
"scripts": {"generate": "node --watch index.js"},
4-
"dependencies": {"ethers": "^5.7.2"}
3+
"scripts": { "generate": "node --watch index.js" },
4+
"dependencies": { "ethers": "^5.7.2" }
55
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ console.log('Mnemonic:', wallet.mnemonic.phrase)
4848
⚠️ **CRITICAL**: Anyone with your private key or mnemonic can spend your funds.
4949

5050
**Do:**
51+
5152
- Store both in a password manager.
5253
- Write the mnemonic on paper and keep it safe.
5354
- Never share them with anyone.
5455

5556
**Don't:**
57+
5658
- Screenshot or email your credentials.
5759
- Store them in plain text on your computer.
5860
- Reuse this wallet for large amounts in production.
@@ -79,13 +81,17 @@ The Nimiq Wallet supports Polygon and makes managing tokens easier than the comm
7981
You need two types of tokens:
8082

8183
### USDC (for transfers)
84+
8285
Visit **https://faucet.circle.com/** to get testnet USDC that works on mainnet. You will need 2-5 USDC to complete the gasless lessons.
8386

8487
### POL (for gas in Lesson 2)
88+
8589
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.
8690

8791
### USDT (no faucet available)
92+
8893
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:
94+
8995
- Purchase USDT on an exchange and withdraw to Polygon
9096
- Swap USDC for USDT using a DEX like Uniswap
9197
- Bridge USDT from Ethereum mainnet
@@ -109,6 +115,7 @@ Replace that placeholder with your actual private key. Never commit files with y
109115
## Verify Your Setup
110116

111117
Before moving forward, confirm:
118+
112119
- ✅ Private key and mnemonic are stored securely
113120
- ✅ Wallet address is funded with USDC and POL
114121
- ✅ You understand the security risks

src/content/tutorial/7-gasless-transfers/2-introduction/_files/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ethers } from 'ethers'
2-
import { POLYGON_RPC_URL, TRANSFER_AMOUNT_USDT } from './lib/config.js'
32
import { checkBalances } from './lib/balances.js'
3+
import { POLYGON_RPC_URL, TRANSFER_AMOUNT_USDT } from './lib/config.js'
44

55
// 🔐 WALLET SETUP: Paste your private key from Lesson 1 here!
66
// ⚠️ This wallet needs USDT on Polygon MAINNET (not testnet)
@@ -80,7 +80,7 @@ async function main() {
8080

8181
// Convert to USDT (simplified - in production use oracle)
8282
const POL_PRICE = 0.50 // $0.50 per POL (example)
83-
const feeInUSD = parseFloat(ethers.utils.formatEther(costWithPct)) * POL_PRICE
83+
const feeInUSD = Number.parseFloat(ethers.utils.formatEther(costWithPct)) * POL_PRICE
8484
const feeInUSDT = (feeInUSD * 1.10).toFixed(6) // 10% buffer
8585
console.log(' • Fee in USDT:', feeInUSDT, 'USDT')
8686

@@ -115,6 +115,6 @@ async function main() {
115115
console.log('\n🎉 Each lesson builds on the previous one!\n')
116116
}
117117

118-
main().catch(error => {
118+
main().catch((error) => {
119119
console.error('\n❌ Error:', error.message)
120120
})

src/content/tutorial/7-gasless-transfers/2-introduction/_files/lib/balances.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ethers } from 'ethers'
2-
import { USDT_ADDRESS, USDT_ABI, USDT_DECIMALS } from './config.js'
2+
import { USDT_ABI, USDT_ADDRESS, USDT_DECIMALS } from './config.js'
33

44
export async function checkBalances(provider, wallet) {
55
const polBalance = await provider.getBalance(wallet.address)
@@ -11,6 +11,6 @@ export async function checkBalances(provider, wallet) {
1111
pol: polBalance,
1212
usdt: usdtBalance,
1313
polFormatted: ethers.utils.formatEther(polBalance),
14-
usdtFormatted: ethers.utils.formatUnits(usdtBalance, USDT_DECIMALS)
14+
usdtFormatted: ethers.utils.formatUnits(usdtBalance, USDT_DECIMALS),
1515
}
1616
}

src/content/tutorial/7-gasless-transfers/2-introduction/_files/lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const USDT_ADDRESS = '0xc2132D05D31c914a87C6611C10748AEb04B58e8F'
44
export const USDT_DECIMALS = 6
55

66
export const USDT_ABI = [
7-
'function balanceOf(address) view returns (uint256)'
7+
'function balanceOf(address) view returns (uint256)',
88
]
99

1010
export const TRANSFER_AMOUNT_USDT = '0.01'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"gasless-demo","version":"1.0.0","type":"module","scripts":{"demo":"node --watch index.js"},"dependencies":{"ethers":"^5.7.2","@opengsn/common":"^2.2.6","axios":"^1.6.0"}}
1+
{ "name": "gasless-demo", "type": "module", "version": "1.0.0", "scripts": { "demo": "node --watch index.js" }, "dependencies": { "@opengsn/common": "^2.2.6", "axios": "^1.6.0", "ethers": "^5.7.2" } }

src/content/tutorial/7-gasless-transfers/2-introduction/_solution/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ethers } from 'ethers'
2-
import { POLYGON_RPC_URL, TRANSFER_AMOUNT_USDT } from './lib/config.js'
32
import { checkBalances } from './lib/balances.js'
3+
import { POLYGON_RPC_URL, TRANSFER_AMOUNT_USDT } from './lib/config.js'
44

55
// 🔐 WALLET SETUP: Paste your private key from Lesson 1 here!
66
// ⚠️ This wallet needs USDT on Polygon MAINNET (not testnet)
@@ -80,7 +80,7 @@ async function main() {
8080

8181
// Convert to USDT (simplified - in production use oracle)
8282
const POL_PRICE = 0.50 // $0.50 per POL (example)
83-
const feeInUSD = parseFloat(ethers.utils.formatEther(costWithPct)) * POL_PRICE
83+
const feeInUSD = Number.parseFloat(ethers.utils.formatEther(costWithPct)) * POL_PRICE
8484
const feeInUSDT = (feeInUSD * 1.10).toFixed(6) // 10% buffer
8585
console.log(' • Fee in USDT:', feeInUSDT, 'USDT')
8686

@@ -115,6 +115,6 @@ async function main() {
115115
console.log('\n🎉 Each lesson builds on the previous one!\n')
116116
}
117117

118-
main().catch(error => {
118+
main().catch((error) => {
119119
console.error('\n❌ Error:', error.message)
120120
})

src/content/tutorial/7-gasless-transfers/2-introduction/_solution/lib/balances.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ethers } from 'ethers'
2-
import { USDT_ADDRESS, USDT_ABI, USDT_DECIMALS } from './config.js'
2+
import { USDT_ABI, USDT_ADDRESS, USDT_DECIMALS } from './config.js'
33

44
export async function checkBalances(provider, wallet) {
55
const polBalance = await provider.getBalance(wallet.address)
@@ -11,6 +11,6 @@ export async function checkBalances(provider, wallet) {
1111
pol: polBalance,
1212
usdt: usdtBalance,
1313
polFormatted: ethers.utils.formatEther(polBalance),
14-
usdtFormatted: ethers.utils.formatUnits(usdtBalance, USDT_DECIMALS)
14+
usdtFormatted: ethers.utils.formatUnits(usdtBalance, USDT_DECIMALS),
1515
}
1616
}

src/content/tutorial/7-gasless-transfers/2-introduction/_solution/lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const USDT_ADDRESS = '0xc2132D05D31c914a87C6611C10748AEb04B58e8F'
44
export const USDT_DECIMALS = 6
55

66
export const USDT_ABI = [
7-
'function balanceOf(address) view returns (uint256)'
7+
'function balanceOf(address) view returns (uint256)',
88
]
99

1010
export const TRANSFER_AMOUNT_USDT = '0.01'

0 commit comments

Comments
 (0)