Sub topic 9
Sending a native coin step by step
This chapter assumes you know what a private key, an address, a network, gas and a nonce are. Earlier chapters covered each of them. Here they are combined into one repeatable procedure for sending a native coin, which is the asset that pays fees on its network (ETH on Ethereum, for example). You will follow the procedure in a wallet app first, then in code.
The procedure at a glance
A native transfer has the same shape in every wallet. The wallet builds a transaction, you review it, the wallet signs it with your private key, and the network receives it. Most mistakes come from skipping the review.
Step 1: Select the network
Confirm which network the wallet is currently using. The same address can exist on several EVM-compatible networks (Ethereum, Base, Arbitrum, Polygon and others), and the same coin name can appear on more than one of them. A transfer on the wrong network does not fail. It succeeds on that network, and the recipient may not be able to access the funds there.
Check two things:
- The network the recipient expects. Ask them, or read it from the invoice.
- The network name shown in your wallet at the top of the send screen.
Step 2: Enter and verify the recipient
Paste the address instead of typing it. Then compare the first and last several characters with the source. Do not rely on the first few characters alone, because address-poisoning scams create look-alike addresses that share a prefix and suffix with one you used before.
Rules that prevent most losses:
- Copy the address from the recipient's own account, not from your transaction history.
- Send a small test amount first when the value is large or the recipient is new.
- Be careful with ENS names or other name services. Confirm that the name resolves to the address you expect before you sign.
Step 3: Enter the amount
Wallets show the amount in whole coins, such as 0.01 ETH. The network itself works in the smallest unit (wei for Ethereum, where 1 ETH is 10^18 wei). Libraries convert between the two for you, and you should always use the conversion function instead of writing the large integer by hand.
Keep enough of the native coin to pay the fee. If you hold 1.00 ETH and try to send exactly 1.00 ETH, the transaction cannot pay for gas, and the wallet either rejects it or offers a "send max" amount that is slightly lower.
Step 4: Review the fee
On a fee-market network such as Ethereum, a transaction carries these fee fields:
| Field | Meaning |
|---|---|
| Gas limit | The maximum units of work you allow. A plain native transfer uses 21,000. |
| Base fee | The per-gas price set by the network and burned. You cannot negotiate it. |
| Priority fee (tip) | An extra per-gas payment to the block producer for faster inclusion. |
| Max fee per gas | The most you will pay per gas, covering base fee plus tip. |
The maximum cost is gas limit multiplied by max fee per gas. The amount you actually pay is usually lower, because you pay the real base fee, not your ceiling. For a plain transfer, the gas limit is fixed at 21,000, so the fee is easy to estimate. If the wallet proposes a much larger gas limit for a native coin transfer to an ordinary address, the recipient may be a smart contract, and you should find out why before continuing.
Step 5 and 6: Sign and broadcast
When you confirm, the wallet encodes the transaction fields (chain ID, nonce, recipient, value, gas settings), signs them with your private key, and sends the signed bytes to a node. The signature proves you authorized exactly those fields. Changing any field, including the amount or the recipient, invalidates the signature.
The chain ID is part of the signed data. It stops a transaction signed for one network from being replayed on another. It does not stop you from choosing the wrong network in step 1.
After broadcast, the node returns a transaction hash. This hash identifies the transaction from this point on. Keep it. A hash returned by the node means the node accepted the transaction into its pool. It does not mean the transaction is in a block.
Step 7: Wait for inclusion and confirmations
The transaction waits in the mempool (the pool of pending transactions) until a block producer includes it. Once included, it has one confirmation. Each later block adds one more. The receipt has a status of 1 for success or 0 for failure. A failed transaction still consumes gas.
A block explorer lets you check the state by hash. Look for:
- Status: pending, success or failed.
- Block number and confirmations.
- From, To and Value fields that match what you intended.
- Transaction fee actually paid.
Doing it in code
The following script performs the same steps with ethers v6. It signs and broadcasts a native transfer of 0.01, waits for inclusion, and reads the receipt status. Use a testnet RPC URL and a throwaway key while learning, and replace the placeholder recipient address.
import { JsonRpcProvider, Wallet, parseEther } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const wallet = new Wallet(process.env.PRIVATE_KEY, provider);
const tx = await wallet.sendTransaction({
to: "0x0000000000000000000000000000000000000001",
value: parseEther("0.01"),
});
console.log("Submitted:", tx.hash);
const receipt = await tx.wait();
console.log("Status:", receipt.status === 1 ? "success" : "failed");How the code maps to the steps:
JsonRpcProvider(process.env.RPC_URL)is step 1. The RPC URL decides which network you talk to.tois step 2, andparseEther("0.01")is step 3. It converts 0.01 into wei.- Fees (step 4) are filled in automatically. The library asks the node for the gas estimate and current fee data. To control them, pass
maxFeePerGas,maxPriorityFeePerGasorgasLimitin the same object. sendTransactionsigns (step 5) and broadcasts (step 6). The nonce is also filled in automatically from the account's current transaction count.tx.wait()is step 7. By default it resolves after one confirmation.
Checking before you send
Add a few checks to the script so it fails before spending anything. This version checks the network, the balance and the address format.
import { JsonRpcProvider, Wallet, parseEther, isAddress, formatEther } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const wallet = new Wallet(process.env.PRIVATE_KEY, provider);
const to = "0x0000000000000000000000000000000000000001";
const value = parseEther("0.01");
if (!isAddress(to)) throw new Error("Invalid recipient address");
const network = await provider.getNetwork();
console.log("Chain ID:", network.chainId.toString());
const balance = await provider.getBalance(wallet.address);
const feeData = await provider.getFeeData();
const maxFee = 21000n * feeData.maxFeePerGas;
if (balance < value + maxFee) {
throw new Error(`Insufficient funds: have ${formatEther(balance)}`);
}
const tx = await wallet.sendTransaction({ to, value });
console.log("Submitted:", tx.hash);
const receipt = await tx.wait();
console.log("Status:", receipt.status === 1 ? "success" : "failed");The balance check uses the worst case, which is the transfer amount plus the full gas limit at the maximum fee per gas. If you want to confirm the chain ID against an expected value, compare network.chainId with a number such as 11155111n for Sepolia and stop on a mismatch.
Common failure points
| Symptom | Likely cause | What to do |
|---|---|---|
| Wallet says "insufficient funds for gas" | Balance does not cover amount plus maximum fee | Lower the amount or add native coin |
| Transaction stays pending | Fee below current base fee, or an earlier nonce is stuck | Wait, or speed up or replace it |
| Status is failed | Execution reverted, often because the recipient is a contract that rejects plain transfers | Check the explorer for the revert reason |
| Funds sent but recipient sees nothing | Wrong network, or the recipient is looking at another account | Verify the network and address on an explorer |
| `invalid address` error in code | Typo, or wrong checksum capitalization | Re-copy the address from its source |
A checklist to reuse
- Network matches what the recipient expects.
- Address pasted and compared at both ends.
- Test transfer sent first for large or new recipients.
- Amount plus fee fits within the balance.
- Fee settings suit how urgent the transfer is.
- Transaction hash saved after broadcast.
- Explorer shows success and enough confirmations.
Exercise
You hold exactly 0.5 of a network's native coin. You try to send 0.5 and the wallet refuses, saying funds are insufficient. A plain transfer uses 21,000 gas and your max fee per gas is 30 gwei (1 gwei is 10^-9 of the coin). What is the maximum fee, and what is the largest amount you can send without risking the same error?
Show answer
The maximum fee is 21,000 × 30 gwei = 630,000 gwei = 0.00063 of the coin. The largest safe amount is 0.5 − 0.00063 = 0.49937. Sending the full balance fails because the amount alone leaves nothing to cover gas.
Exercise
Your script prints a transaction hash, but a block explorer shows no block number for it. Does this mean the transfer succeeded? What should you check next?
Show answer
No. The hash only shows that a node accepted the transaction into its pool. With no block number it is still pending. Check whether the fee is above the current base fee, whether an earlier transaction from the same account with a lower nonce is stuck, and wait for inclusion before treating the payment as complete.