September 28, 2023

Full BSC Node Guide – How to Run BNB Smart Chain Nodes

Table of Contents

Are you looking for the easiest way to run a BNB Smart Chain (BSC) node? Then you’ll definitely want to stick around! In today’s guide, we’ll show you how to seamlessly run a BSC node with Moralis – the industry’s leading Web3 infrastructure provider. Moralis enables you to deploy a node effortlessly with just a couple of clicks, handling all the technical complexities on your behalf. Are you eager to start? If so, here’s a concise, three-step summary of how to run your BSC node with Moralis: 

  • Step 1 – Sign up for free with Moralis.
  • Step 2 – Log in, navigate to the ”Nodes” tab, and create a new BSC node:
Step 2 - Log in, navigate to the ”Nodes” tab, and create a new BSC node:
  • Step 3 – Copy and integrate one of your BSC node URLs into your dapp:
Step 3 - Copy and integrate one of your BSC node URLs into your dapp:

That’s it! Running a BSC node doesn’t have to be more challenging than that when using Moralis. However, if you want a more in-depth breakdown, check out our nodes documentation page or join us in this tutorial as we cover the process in further detail!

Also, if you wish to run your own nodes, don’t forget to sign up with Moralis. You can set up an account for free, and you’ll gain immediate access to our top-tier development resources!

Overview 

Setting up and maintaining the infrastructure you need to run a BSC node yourself is both a time-consuming and resource-intensive process. First of all, operating a full or archive node demands a lot of computational power, storage capacity, and bandwidth. Moreover, each blockchain network has its own set of nodes, meaning you’ll need to run and maintain a separate one for each network you interact with. And as you can imagine, this can quickly become a bothersome task if you’re looking to build cross-chain compatible decentralized applications (dapps). Fortunately, you can now remove these hurdles by using a top-tier Web3 infrastructure provider like Moralis! 

Moralis logo in grey text with its "M" logo on the left

With Moralis, you can seamlessly set up nodes for multiple blockchain networks at the click of a few buttons. We essentially take care of all the underlying complexities, allowing you to focus on building dapps that will blow the competition out of the water. So, whether you’re building a cryptocurrency wallet, portfolio tracker, or any other Web3 project, this read is for you. Let’s dive straight into it!

What is a BSC Node? 

A BSC node is a device, typically a computer or server, that participates in the BNB Smart Chain network by running the protocol’s client software. These nodes play an essential role in the blockchain’s operation by validating transactions, preserving historical data, and enhancing the network’s security!

Showing how a BNB Smart Chain (BSC) node looks like - graphic art illustration

The BSC network consists of a distributed set of nodes that work together to propagate data, providing a synchronized and unified state of the blockchain. This collaborative process is fundamental to maintaining the integrity and functionality of the entire system. 

Nodes are pivotal for the BSC network, fulfilling several essential functions. Below, we highlight three key examples:

  • Transaction Validation: When users initiate transactions on the BSC network, they get broadcasted to nodes. The nodes then verify the validity of the transaction by checking various factors. For instance, they make sure that the sender has sufficient funds and that verifications are legitimate.
  • On-Chain Data Storage: Certain BSC nodes specialize in maintaining a comprehensive record of the BSC blockchain, including transaction and smart contract data. These nodes update their records in real-time as new transactions are executed on the network, ensuring the data remains current and accurate.
  • Blockchain Interactions: Nodes enable users and developers to interact with the BSC network. With nodes, it’s possible to execute transactions, deploy smart contracts, and query on-chain data. As such, BSC nodes are critical for anyone looking to build dapps. 

Now that we understand BSC nodes, let’s explore the easiest way to set up and run one!

The Easiest Way to Run a BSC Node – Introducing Moralis 

Moralis is the industry’s premier Web3 infrastructure provider, giving you the resources you need to build top-tier dapps. In our suite of development tools, you’ll find ten+ use case-specific APIs and nodes for all major networks, including BSC, Polygon, Ethereum, etc. Consequently, when using Moralis, you can seamlessly build everything from cryptocurrency wallets to decentralized exchanges (DEXs) that will blow the competition out of the water! 

Run a BNB Smart Chain (BSC) Node with Moralis - Marketing banner

So, why should you build with Moralis? 

  • Simple: Both our APIs and RPC nodes feature are fully coss-chain compatible, supporting all the biggest blockchains. In turn, when using Moralis, it’s possible to streamline your developer experience as you no longer need to bother with multiple providers for each chain. 
  • Comprehensive: Our APIs are designed to minimize the requests you need to build sophisticated dapps. So, when using Moralis, you get more data with fewer API calls. 
  • Trusted: Moralis is trusted by 100,000+ developers and large enterprise customers, including MetaMask, Opera, Blockchain.com, and many others. 

That gives you an overview of Moralis. Now, let’s show you how to seamlessly run a BSC node! 

3-Step Tutorial: How to Seamlessly Run a BSC Node 

Thanks to the accessibility of Moralis, you can set up and run a BSC node in three simple steps: 

  1. Sign Up with Moralis
  2. Create a BSC Node
  3. Integrate Your BSC Node

Step 1: Sign Up with Moralis

If you haven’t already, register a free account with Moralis by clicking on the ”Start for Free” button at the top of Moralis’ homepage: 

Signing up for a free Moralis account

Step 2: Create a BSC Node

With an account at hand, head on over to the ”Nodes” tab and click on ”+ Create a New Node”:

With an account at hand, head on over to the ”Nodes” tab and click on ”+ Create a New Node”:

Select ”Binance” followed by ”Mainnet” and hit the ”Create Node” button: 

Select ”Binance" followed by ”Mainnet” and hit the ”Create Node” button: 

Doing so will generate two new site URLs: 

two generated node URLs (site URLs)

Step 3: Integrate Your BSC Node 

From here, you simply need to copy one of the URLs and use it to integrate the node into your dapp: 

copy one of the URLs and use it to integrate the node into your dapp

That’s it; running a BSC node doesn’t have to be more challenging than that when working with Moralis. From here, you can now start to make RPC calls to your newly created node without breaking a sweat!

How to Make RPC Calls to a BCS Node 

Now that you know how to set up and run a BSC node with Moralis, we’ll briefly show you how to use it to get on-chain data. Specifically, we will guide you through the process of retrieving the native balance of a BSC address using the ethers library!

To get started, open your preferred IDE, create a new folder, and initialize a new project by executing the following command in your terminal:

npm init

Next, install the ethers library with the terminal command below: 

npm install ethers

You can then open your project’s ”package.json” file and add ”type”: ”module” to the list: 

add ”type”: ”module” to the code list

From here, create a new ”index.js” file and add the following code: 

import { ethers } from "ethers";

const provider = new ethers.providers.JsonRpcProvider("YOUR_NODE_URL");

const address = "0xf977814e90da44bfa03b6295a0616a897441acec";

const balance = await provider.getBalance(address);
console.log("Balance: ", ethers.utils.formatEther(balance));

Before you can run the script above, you need to make some minor alterations to the code. First, replace YOUR_NODE_URL with one of your Moralis node URLs. Next, configure the address parameter to fit your query. 

From here, you simply need to run the script by executing the following terminal command in the root folder of the project: 

node index.js

Doing so will give you the native balance of the specified wallet. Here’s an example of what it might look like: 

Balance:  11023881.30

Congratulations; you now know how to make RPC calls to your BSC node!

For a more detailed breakdown and more examples, please check out the video below from the Moralis YouTube channel: 

BSC Node Use Cases 

There are all sorts of use cases for BSC nodes, and we won’t be able to cover them all in this article. Instead, we’ll narrow it down and focus on three prominent examples: 

  • Becoming a Validator: A prominent use case for nodes is to become a validator. Validators stake cryptocurrencies in order to become eligible to verify new blocks. If they get selected, they earn cryptocurrencies in return for their work. 
  • Smart Contract Deployment: BSC nodes can also be used to deploy smart contracts. As such, they are useful for Web3 developers that need smart contracts for their dapps. 
  • Read and Write On-Chain Data: It’s also possible to use a blockchain node to read and write on-chain data. This includes executing transactions and fetching information like the native balance of an address, the current block number, etc. 
Highlighting use cases for a BSC node, including read and write data, smart contract deployment, and validator capabilities

Easiest Way to Query On-Chain Data – Diving Into Moralis’ Web3 APIs 

While it’s possible to interact with the BSC network using a node, it’s not always an ideal option. For instance, querying a blockchain directly with a node yields raw, unformatted data. As such, before it’s usable, you must decode, interpret, and convert it into a suitable format. 

Nodes are chain-specific. This means you need to run multiple nodes to access data from several blockchain networks, which can escalate costs significantly if you’re building cross-chain dapps. Fortunately, Moralis offers a streamlined alternative! 

Moralis’ Web3 APIs allow you to effortlessly access decoded, complex on-chain data through a few lines of code. This includes everything from ERC-20 balances, the history of an address, real-time metadata, prices, and much more.

However, to highlight the accessibility of querying on-chain data with Moralis, we’ll explore three prominent APIs you’ll likely find helpful when building dapps:

  1. Wallet API
  2. Token API
  3. NFT API

If you’d like to explore all our premier interfaces, please visit our Web3 API page, where you’ll find the rest!  

Wallet API 

The Wallet API is the perfect tool for anyone looking to build wallets or integrate wallet functionality into their dapp. This premier interface supports 500+ million addresses across all major chains, including BSC, Ethereum, Polygon, etc., ensuring that all your wallet-related data needs are covered! 

With the Wallet API, you only need single lines of code to get a wallet’s full history, balances, profitability, net worth, and much more. So, when working with Moralis, you can seamlessly streamline reliable on-chain data integration for your wallets, portfolio tracker, or any other projects. 

To highlight the accessibility of the Wallet API, let’s look at the script below for fetching the history of any address: 

import fetch from 'node-fetch';

const options = {
method: 'GET',
headers: {
  accept: 'application/json',
  'X-API-Key': 'YOUR_API_KEY'
},
};

fetch(
'https://deep-index.moralis.io/api/v2.2/wallets/0xf977814e90da44bfa03b6295a0616a897441acec/history?chain=bsc&order=DESC',
options
)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));

In return for calling our Wallet History endpoint above, you’ll get all the native transactions, ERC-20 transfers, NFT trades, contract interactions, and much more from the given address. In addition, the response also contains address labels, automatic categories, summaries, and much more, giving you fully decoded data straight out of the box. Here’s an example of what the response might look like: 

{
  //...
  "result": [
    {
      "hash": "0x84925d82c62e319accdc5390d45d3cc0b3025ebc65d5bc9ac7346e57ea26fb21",
      "nonce": "25750370",
      "transaction_index": "61",
      "from_address": "0x8894e0a0c962cb723c1976a4421c95949be2d4e3",
      "from_address_label": "Binance: Hot Wallet 6",
      "to_address": "0x4338665cbb7b2485a8855a139b75d5e34ab0db94",
      "to_address_label": "Binance-Peg Litecoin Token (LTC)",
      "value": "0",
      "gas": "207128",
      "gas_price": "2000000000",
      "receipt_cumulative_gas_used": "6065676",
      "receipt_gas_used": "34527",
      "receipt_status": "1",
      "block_timestamp": "2024-04-25T07:42:50.000Z",
      "block_number": "38163071",
      "block_hash": "0xccd07bd576479a9fc183d45b0b730c790d2c1e1741d1c893984ed06fa8831c8e",
      "nft_transfers": [],
      "erc20_transfers": [
        {
          "token_name": "Litecoin Token",
          "token_symbol": "LTC",
          "token_logo": "https://logo.moralis.io/0x38_0x4338665cbb7b2485a8855a139b75d5e34ab0db94_2fe2a7c5d2314d55a49514978d6577f9",
          "token_decimals": "18",
          "from_address": "0x8894e0a0c962cb723c1976a4421c95949be2d4e3",
          "from_address_label": "Binance: Hot Wallet 6",
          "to_address": "0xf977814e90da44bfa03b6295a0616a897441acec",
          "to_address_label": "Binance: Hot Wallet 20",
          "address": "0x4338665cbb7b2485a8855a139b75d5e34ab0db94",
          "log_index": 149,
          "value": "17275990000000000000000",
          "possible_spam": false,
          "verified_contract": true,
          "direction": "receive",
          "value_formatted": "17275.989999999998"
        }
      ],
      "method_label": null,
      "native_transfers": [],
      "summary": "Received 17,275.99 LTC from 0x88...d4e3",
      "possible_spam": false,
      "category": "token receive"
    },
    //...
  ]
}

Token API 

Moralis’ Token API is the ultimate interface for reliable, accurate, and simple ERC-20 data integrations. The Token API supports every single crypto across all the biggest chains. This includes stablecoins like USDT, meme coins like Shiba Inu, and much more. So, if you’re building a dapp and need seamless access to ERC-20 token data, we have got you covered! 

With the Token API, you can seamlessly fetch real-time token balances, prices, metadata, and more with just single endpoints. As such, if you’re building a DEX, portfolio tracker, token explorer, or any other platform, make sure to use Moralis’ Token API for your data needs to build faster and more efficiently. 

To highlight the power of building with the Token API, we’ll now look at a brief script for fetching the token balances with prices of any wallet: 

import fetch from 'node-fetch';

const options = {
method: 'GET',
headers: {
  accept: 'application/json',
  'X-API-Key': 'YOUR_API_KEY'
},
};

fetch(
'https://deep-index.moralis.io/api/v2.2/wallets/0xf977814e90da44bfa03b6295a0616a897441acec/tokens?chain=bsc',
options
)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));

In return for running the script above, you’ll get a list of all tokens held by the wallet in question. In addition, each element is fully enriched with prices, price changes over time, metadata, and much more. As such, with just this single endpoint, you get everything you need to build a comprehensive portfolio view of a wallet: 

{
  //...
  "result": [
    {
      "token_address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
      "symbol": "BNB",
      "name": "Binance Chain Native Token",
      "logo": "https://cdn.moralis.io/bsc/0x.png",
      "thumbnail": "https://cdn.moralis.io/bsc/0x_thumb.png",
      "decimals": 18,
      "balance": "11023881307971172569412824",
      "possible_spam": false,
      "verified_contract": true,
      "balance_formatted": "11023881.307971172569412824",
      "usd_price": 608.8959640214011,
      "usd_price_24hr_percent_change": 0.17980622041811564,
      "usd_price_24hr_usd_change": 1.0928677749450344,
      "usd_value": 6712396836.274611,
      "usd_value_24hr_usd_change": 12047644.63630104,
      "total_supply": null,
      "total_supply_formatted": null,
      "percentage_relative_to_total_supply": null,
      "native_token": true,
      "portfolio_percentage": 3.1453
    },
  ]
}

NFT API 

The NFT API is the industry’s premier tool for NFT data, supporting over three million collections. This includes everything from established projects like Pudgy Penguins to tokens that dropped just seconds ago. As such, if you’re building NFT-based projects, make sure to leverage Moralis as your provider for faster and streamlined data integration! 

With single lines of code, you can leverage the NFT API to get token balances, up-to-date metadata, prices, and much more. As such, building everything from NFT marketplaces to Web3 games has never been easier. 

To highlight the power of the NFT API, let’s look at a short script for fetching the NFT balance of a wallet: 

import fetch from 'node-fetch';

const options = {
method: 'GET',
headers: {
  accept: 'application/json',
  'X-API-Key': 'YOUR_API_KEY'
},
};

fetch(
'https://deep-index.moralis.io/api/v2.2/nft/0x0a8901b0e25deb55a87524f0cc164e9644020eba/1?chain=bsc',
options
)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));

In return for calling the endpoint above, you’ll get an array of all NFTs held by the specified address. The response will also be enriched with metadata, including logos, attributes, etc. Here’s an example of what it might look like: 

{
  amount: '1',
  token_id: '1',
  token_address: '0x0a8901b0e25deb55a87524f0cc164e9644020eba',
  contract_type: 'ERC721',
  owner_of: '0xa8f3eaabe4da4ae3618c87633b7d08541595c5c0',
  last_metadata_sync: '2024-04-09T05:00:09.507Z',
  last_token_uri_sync: '2024-04-09T05:00:09.360Z',
  metadata: '{"id":1,"name":"Pancake Squad #1","description":"10,000 unique, randomly-generated PancakeSwap NFTs from the mind of Chef Cecy Meade. Join the squad.","attributes":[{"trait_type":"background","value":"Orange"},{"trait_type":"bunny","value":"Pink"},{"trait_type":"clothes","value":"Jumpsuit"},{"trait_type":"eyes","value":"Flat"},{"trait_type":"mouth","value":"Grumpy"},{"trait_type":"ear","value":"None"},{"trait_type":"hat","value":"None"}],"image":"ipfs://QmaYTLuEoP35NcBKLsyPMzwDpebbZWukdEkzeGV9fVcUCt/pancakesquad1.png"}',
  block_number: '24196839',
  block_number_minted: '11560524',
  name: 'Pancake Squad',
  symbol: 'PS',
  token_hash: '24caa8515525bd1e2219331133aae166',
  token_uri: 'https://ipfs.moralis.io:2053/ipfs/QmNWEEuxdugy7xxbmViU42TSr9SCkD2AyNgxGp67FrkZ9k/pancakesquad1.json',
  minter_address: '0x0ff59a1f7baa037b5a38b09f3c90e8634dda4f1c',
  verified_collection: false,
  possible_spam: false,
  collection_logo: 'https://i.seadn.io/gcs/files/372cd31290f7ea995e71fd6c8963288c.jpg?w=500&auto=format',
  collection_banner_image: 'https://i.seadn.io/gcs/files/0f63c67e2d2a8fa5e05a2be1d80bf2de.webp?w=500&auto=format'
}

Summary: How to Run a BSC Node

Setting up and maintaining nodes yourself can be a tedious and time-consuming task. For instance, running a full or archive node demands a lot of computational power, storage, and bandwidth. What’s more, all blockchain networks have their own set of nodes, meaning you need to run a separate one for all the chains you’re interacting with. Fortunately, you can now circumvent these hurdles with a premier Web3 infrastructure provider like Moralis! 

With Moralis, you can now set up a BSC node in three simple steps: 

  • Step 1 – Sign up for free with Moralis.
  • Step 2 – Log in, navigate to the ”Nodes” tab, and create a new BSC node:
Step 2 - Log in, navigate to the ”Nodes” tab, and create a new BSC node:
  • Step 3 – Copy and integrate one of your BSC node URLs into your project: 
Step 3 - Copy and integrate one of your BSC node URLs into your project: 

That’s it; running a BSC node doesn’t have to be more challenging than that when working with Moralis! 

If you liked this BSC node tutorial, consider checking out more content here at Moralis. For instance, read our Polygon node guide or learn how to build a crypto wallet timeline

Also, if you want to set up your own BSC node, don’t forget to sign up with Moralis. You can create an account without paying a dime, and you’ll gain instant access to both our APIs and nodes! 

Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
April 18, 2024

Moralis Launches Moralis Nodes

September 25, 2022

Full Guide: How to Build an Ethereum Dapp in 5 Steps

December 30, 2022

Essential Web3 Programming Languages for 2023

January 24, 2024

Why Did Crypto Crash Today? Crypto Market Intelligence for Your Users

December 29, 2022

Web3 Wallet Tracker – How to Create a Firebase Web3 Wallet Tracker

March 7, 2023

How to Create a Blockchain Explorer

January 23, 2023

Monitor an Ethereum Address – Crypto Wallet Tracking for EVM Chains

November 22, 2022

Exploring the Ultimate ERC20 Token API