Sending POL Transactions
With your wallet funded, it is time to perform a live transaction on Polygon Amoy. Understand the concept, walk through each step deliberately, and then experiment on your own.
Essential Context: POL
POL (formerly called MATIC) is Polygonβs native currency. Every on-chain action pays a small amount of POL as a gas fee, which compensates validators for processing your transaction.
- Token type: Native protocol asset, similar to ETH on Ethereum.
- Gas currency: All Polygon fees are charged in POL.
- Decimals: 18 (same as ETH).
Keep a small buffer of POL in your wallet; even ERC20 transfers consume it for gas.
π‘ 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!
Step 1: Load the Wallet
Reuse the .env-backed wallet you created earlier so you are not juggling multiple keys.
import dotenv from 'dotenv'import { ethers } from 'ethers'
dotenv.config()
const RPC_URL = 'https://rpc-amoy.polygon.technology'const provider = new ethers.providers.JsonRpcProvider(RPC_URL)const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider)
console.log('π Sender Address:', wallet.address)Step 2: Confirm Available POL
Always confirm you have enough POL to cover the transfer plus gas.
const balance = await provider.getBalance(wallet.address)console.log('π° Balance:', ethers.utils.formatEther(balance), 'POL')Aim for at least 0.1 POL. If you are low, revisit the faucet before continuing.
Step 3: Prepare the Transfer
Choose a recipient address (another wallet you control works well) and decide how much to send.
const RECIPIENT = '0x...' // Replace with any addressconst AMOUNT_POL = '0.0001' // Minimal amount for demo
console.log('\nπ€ Preparing Transaction')console.log('ββ To:', RECIPIENT)console.log('ββ Amount:', AMOUNT_POL, 'POL')Step 4: Broadcast the Transaction
Let ethers.js handle signing and broadcasting with a single call.
const tx = await wallet.sendTransaction({ to: RECIPIENT, value: ethers.utils.parseEther(AMOUNT_POL)})
console.log('\nβ³ Transaction Sent!')console.log('ββ Hash:', tx.hash)console.log('ββ Waiting for confirmation...')sendTransactioncreates and submits the transaction.parseEtherconverts human-readable POL into wei, the smallest unit.- The transaction hash is your receipt number; keep it handy.
Step 5: Wait for Confirmation
Transactions settle once they are included in a block. Wait for that confirmation before moving on.
const receipt = await tx.wait()
console.log('\nβ
Transaction Confirmed!')console.log('ββ Block:', receipt.blockNumber)console.log('ββ Gas Used:', receipt.gasUsed.toString())console.log('ββ Status:', receipt.status === 1 ? 'Success' : 'Failed')console.log('ββ View on Explorer:', `https://amoy.polygonscan.com/tx/${tx.hash}`)Open the explorer link to see the transaction exactly as validators processed it.
Step 6: Reconcile Balances
Confirm both the transfer amount and the gas cost deducted from your wallet.
const newBalance = await provider.getBalance(wallet.address)const spent = balance.sub(newBalance)
console.log('\nπ Balance Update')console.log('ββ Before:', ethers.utils.formatEther(balance), 'POL')console.log('ββ After:', ethers.utils.formatEther(newBalance), 'POL')console.log('ββ Spent:', ethers.utils.formatEther(spent), 'POL (including gas)')The difference between the sent amount and the total spent reflects the gas fee.
Understanding Gas Fees
Every transfer has two cost components:
- Amount transferred: The value delivered to the recipient.
- Gas fee: The computational cost paid to validators.
Gas Fee = Gas Used Γ Gas Price- Gas Used represents the work done (a simple transfer is roughly 21,000 units).
- Gas Price fluctuates with network demand.
On Polygon Amoy, these fees are tiny, but cultivating the habit of checking them now will pay off on higher-cost networks.
Try-It Ideas
- Send POL to yourself to see how the receipt looks when sender and recipient match.
- Experiment with smaller or larger amounts and observe how gas usage stays consistent.
- Submit multiple transactions in a row and compare their block numbers and confirmation times.
Wrap-Up
You have now:
- β Broadcast your first Polygon transaction.
- β Observed the full confirmation lifecycle.
- β Calculated how gas fees affect balances.
- β Gained confidence working with the POL native token.
Next, you will apply the same discipline to ERC20 tokens by sending USDC.
- npm install
- npm run send