BNB Smart Chain
Bereit, das in der Produktion aufzurufen?
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
BNB Smart Chain
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
JavaScript developers targeting BNB Smart Chain reach for one of two libraries: web3.js, the long-standing workhorse, or ethers.js, the leaner modern alternative. Because BSC speaks the same geth-flavoured JSON-RPC dialect as any EVM network, both libraries run unchanged — you simply hand them the https://bsc.therpc.io/YOUR_API_KEY endpoint and start reading balances or broadcasting transactions on chain 56. For greenfield work we lean toward ethers.js v6. Its tighter API and first-class typings pay off over a project's lifetime, helped by a smaller browser footprint.
Both libraries are under active maintenance and ship regular releases, so either is a safe bet for production BSC code. That said, ethers.js v6 is our recommendation for new projects: its TypeScript support is sharper and its bundle size is meaningfully smaller, which matters when your dApp ships to wallets and mobile browsers.
web3.js is the original and most widely deployed JavaScript API for talking to BNB Smart Chain, and a huge body of tutorials and Stack Overflow answers assumes it. Pull it in with npm install web3, then construct a client by passing your TheRPC BSC URL straight to the constructor: new Web3('https://bsc.therpc.io/YOUR_API_KEY'). From that one instance you get the full web3.eth surface: balance reads in BNB, transaction sends, plus BEP-20 contract calls.
ethers.js is the modern, compact counterpart, written in TypeScript from the ground up so its typings are exact rather than bolted on. Install it with npm install ethers, then open a connection to BSC by handing the endpoint to a provider: new ethers.JsonRpcProvider('https://bsc.therpc.io/YOUR_API_KEY'). That provider becomes your gateway for querying chain 56: it fetches BNB balances, estimates gas, then submits signed transactions.
Neither library needs a separate @types/* package — web3.js and ethers.js both bundle their own declaration files, so the moment you import them your editor knows the shape of every BSC call. The practical wins are immediate. Autocompletion suggests valid method names and parameters. The compiler catches a malformed transaction object before it ever reaches chain 56. And that inline type information doubles as living documentation while you build.
On the server, both libraries run happily under Node.js regardless of your module system. Classic CommonJS projects can pull them in with require(), while ESM projects use import — the same BSC provider setup applies either way, so dropping a chain-56 client into a backend service, a cron job, or an indexer takes no extra ceremony.
In the browser you bring the library in through ES module imports and let a bundler such as webpack or Vite handle the packaging. When a user has an injected wallet like MetaMask configured for BNB Smart Chain, skip the read-only RPC provider and wrap the injected object instead: new ethers.BrowserProvider(window.ethereum). That hands signing control to the wallet while still routing reads across the BSC network.