Base
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Base
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
For JavaScript and TypeScript work on Base there are two main library choices: web3.js and ethers.js. Both are actively maintained and both speak standard EVM JSON-RPC, so either connects to Base at https://base.therpc.io/YOUR_API_KEY against chain ID 8453. For new projects we recommend ethers.js v6 — it has stronger TypeScript support and a smaller bundle, which matters for the browser-heavy consumer apps common in the Base ecosystem.
Both web3.js and ethers.js are actively maintained and production-ready on Base. For new Base projects, prefer ethers.js v6: its first-class TypeScript support and smaller bundle size make it the better default, especially for front-end dApps.
web3.js is the original and most widely used JavaScript API for EVM chains, and it works on Base unchanged. Install it with npm install web3, then instantiate a client by passing your Base endpoint to the constructor: new Web3('https://base.therpc.io/YOUR_API_KEY'). From there, web3.eth exposes balance, transaction, and contract calls against chain ID 8453.
ethers.js is a modern, compact library with first-class TypeScript support, which makes it a natural fit for Base front-ends. Install it with npm install ethers, then connect by passing your Base endpoint to a JsonRpcProvider: new ethers.JsonRpcProvider('https://base.therpc.io/YOUR_API_KEY'). That provider handles reads on chain ID 8453, and you pair it with a Wallet to sign and send transactions.
Both web3.js and ethers.js ship their own type definitions, so you get full typing for your Base code without installing any @types/* package. In practice that means IDE autocompletion for every eth method, compile-time checking that catches a malformed transaction object before it ever hits the Base node, and type signatures that document the API as you write.
Both libraries run in Node.js for backend Base services — indexers, bots, and webhook handlers — and support either CommonJS require() or ESM import, so they drop into whatever module system your project already uses.
In the browser, use ES module imports and let a bundler like webpack or Vite package the library for your Base dApp. When you need a user's wallet — MetaMask, Coinbase Wallet, or another injected provider common in the Base ecosystem — wrap it with new ethers.BrowserProvider(window.ethereum) so the user signs transactions with their own keys while your JsonRpcProvider handles read traffic.