Avalanche
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Avalanche
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
For JavaScript and TypeScript development on the Avalanche C-Chain you have two mature choices: web3.js and ethers.js. Both are actively maintained and both speak standard EVM JSON-RPC, so either connects to https://avalanche.therpc.io/YOUR_API_KEY at chain ID 43114 with AVAX as gas. For new projects we recommend ethers.js v6: it has first-class TypeScript support and a smaller bundle, which matters for browser dApps interacting with Avalanche DeFi like Trader Joe or GMX.
Both web3.js and ethers.js are actively maintained and production-ready against the C-Chain. For new Avalanche projects, ethers.js v6 is the recommended starting point thanks to its stronger TypeScript support and smaller bundle size.
web3.js is the original and one of the most widely used JavaScript APIs for EVM chains, and it works against the Avalanche C-Chain unchanged. Install it with npm install web3, then instantiate new Web3('https://avalanche.therpc.io/YOUR_API_KEY') to get a client for reading AVAX balances and sending transactions on chain 43114.
ethers.js is a modern, compact library with first-class TypeScript support, which makes it a strong default for new C-Chain apps. Install it with npm install ethers, then create new ethers.JsonRpcProvider('https://avalanche.therpc.io/YOUR_API_KEY') to connect to the Avalanche C-Chain. The provider handles reads; pair it with a Wallet to sign and send AVAX transactions.
Both web3.js and ethers.js ship their own type definitions, so there is no separate @types/* package to install for either one when building C-Chain apps in TypeScript. You get IDE autocompletion across the full API, compile-time checking that catches a wrong argument before it ever reaches the Avalanche endpoint, and type signatures that double as inline documentation.
Both libraries run server-side in Node.js — useful for C-Chain indexers, bots, and backends — and support either CommonJS require() or ESM import depending on how your project is configured. The connection string stays the same https://avalanche.therpc.io/YOUR_API_KEY in either module system.
In the browser, import either library as an ES module and let a bundler like webpack or Vite tree-shake and package it for your C-Chain dApp. When the user has MetaMask or another injected wallet, wrap it with new ethers.BrowserProvider(window.ethereum) so the wallet signs AVAX transactions and you can prompt it to switch to the Avalanche C-Chain (43114).