ethers-js

Interact with EVM blockchains using ethers.js v6 providers, signers, and contracts.

6|20|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/andresdefi/cryptoskills --skill ethers-js-andresdefi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ethers-js
Source: https://github.com/andresdefi/cryptoskills/tree/main/skills/ethers-js
Command: npx skills add https://github.com/andresdefi/cryptoskills --skill ethers-js-andresdefi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ethers, and includes references (resource) components.

What problem does it solve? LLMs frequently generate outdated ethers.js v5 code with BigNumber, ethers.utils, and ethers.providers patterns that fail against v6. This Skill provides correct v6 patterns for providers, wallets, contract interaction, ABI encoding, event handling, and error management so generated code works on the first attempt. ## Core Features & Use Cases - v5 to v6 Migration Reference: Complete mapping of BigNumber to native bigint, ethers.utils to top-level exports, and Web3Provider to BrowserProvider, with a quick-detection table for identifying version mismatches. - Provider, Signer, and Contract Patterns: Ready-to-use TypeScript examples for JsonRpcProvider, BrowserProvider, WebSocketProvider, FallbackProvider, Wallet creation, ContractFactory deployment, and read-write contract connections. - Error Handling and Troubleshooting: Structured isError-based handling for CALL_EXCEPTION, INSUFFICIENT_FUNDS, NONCE_EXPIRED, and other v6 error codes, plus a debug checklist for common failures like null receipts and gas estimation errors. - Use Case: Build a backend script that reads ERC-20 balances via Multicall3, sends EIP-1559 transactions with gas control, and listens to Transfer events over WebSocket, all using verified v6 idioms. ## Quick Start Ask the agent to write an ethers.js v6 script that connects a Wallet to a JsonRpcProvider and transfers ERC-20 tokens with receipt verification.

Frequently Asked Questions about ethers-js

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate ethers.js v5 code to v6?

Replace BigNumber with native bigint, move ethers.utils functions to top-level imports like parseEther, and swap ethers.providers.JsonRpcProvider for a top-level JsonRpcProvider import. Also update contract.address to await contract.getAddress() and handle tx.wait() returning null.

How do I connect ethers.js v6 to MetaMask in a browser?

Use BrowserProvider to wrap the EIP-1193 window.ethereum object injected by the wallet. Call await provider.getSigner() to request account access, then use the signer for transactions and the provider for reads.

Why does tx.wait() return null in ethers.js v6?

In v6, tx.wait() returns null when the transaction is dropped or replaced by the network, such as from nonce conflicts or low gas. Always check receipt === null before accessing receipt.status to avoid null reference errors.

Does ethers.js v6 still support BigNumber?

No, v6 removed BigNumber entirely and returns native JavaScript bigint for all uint256 values. Use native operators like +, *, and ===, and convert with BigInt(n) or bigint literals like 123n instead of BigNumber.from().

How do I handle CALL_EXCEPTION errors in ethers.js v6?

Use the isError(error, "CALL_EXCEPTION") type guard to catch contract reverts, then inspect error.reason and error.data for details. You can decode custom errors from error.data using Interface.parseError with the contract's error ABI.

Which provider should I use for real-time event subscriptions?

Use WebSocketProvider for persistent subscriptions like provider.on("block") and contract.on("Transfer"), since JsonRpcProvider only supports polling. Implement reconnection logic on websocket close events for production reliability.