BSC Development Quick Reference Guide

About Binance Smart Chain

Binance Smart Chain (BSC) is a sovereign smart contract blockchain delivering Ethereum Virtual Machine (EVM) compatible programmability and running parallel with Binance Chain. By introducing the Proof of Stake Authority (PoSA) consensus mechanism, BSC has created an ecosystem that allows nodes, token holders, developers, and users to benefit from the blockchain.

Get Your BSC Wallet Ready

In the blockchain world, digital wallet is not the actual container for cryptocurrencies. Rather, it stores pairs of encryption keys that represents ownership at certain address. Each pair of keys stored in digital wallets consists of a public key that is needed to initiate transactions and a matching private key for transaction encryptions and decryptions. Therefore, ownership of keypairs confers full control of the cryptocurrencies at the address associated to the keypairs. In development stage, we create randomized keypairs and a piece of address information through our digital wallet, with which we are able to receive from or send to cryptocurrencies to others. And this is why we have to get our wallet ready for development.

Browser Plugin Wallet

Browser plugin wallet is the most popular choice in blockchain development. It’s easy to set up, install and access the wallet in the browser. Besides that, since majority of blockchain applications are web-based, browser plugin wallet gives an intuitive access to pretty much all DeFi and NFT apps available on the market.

Wallet App

When a smart contract goes live, most of its users access it through a wallet app of their choice.

Preparing BSC Development Environment

Start Development today with BSC Studio

BSC Studio is a powerful yet user-friendly graphic IDE platform, specially designed for BSC. It supports running locally on majority OS, including macOS, Windows and Linux and also on web browsers. Comparing with traditional Ethereum development toolkit like Remix and Ganache, BSC Studio streamlines environment preparation procedure and integrates essential tools for a complete development lifecycle, including a graphic code editor, project manager, keypair manager, block explorer, contract inspector and network manager.

Develop locally with BSC Studio Desktop

BSC Studio Desktop is a great all-in-one IDE platform for BSC developers at all levels. You may download the latest release of BSC Studio Desktop at its Github Repo. BSC Studio currently supports major OS including macOS, Linux and Windows.

Installation

  • macOS: Double click to open BSC-Studio-x.x.x.dmg and drag the app into Application folder.
  • Linux: Double click to open BSC-Studio-x.x.x.AppImage, Select Properties( => Permissions => Execute and tick Allow executing file as program option. Close Properties window and double click to open the application.Please note, different Linux distribution might have different application installation procedure.
  • Windows: Double click to open BSC-Studio-x.x.x.exe

Preparing Prerequisites

Upon first successful startup of BSC Studio, you’ll be directed to a welcome screen where shows a list of prerequisites for BSC Development, including Docker, BSC Node and Truffle.

  • BSC Docker Hub stores Docker images for BSC nodes, which BSC Studio relies on to run BSC node.
  • BSC Truffle is the truffle toolkit used by BSC Studio for project creation and compilation.

Develop online with BSC Studio Web

BSC Studio also offers a web version for developers who wish to develop, compile and run BSC smart contracts online. BSC Studio web inherits most functionalities of the Desktop version but no longer require setting up dependencies on local machines. It’s the perfect choice for BSC developers who wants to try out BSC development without worrying about setting up BSC dependencies locally. Visit bsc.ide.black to experience BSC development on the cloud.

Connecting to BSC networks

BSC primarily offers two networks, namely BSC Mainnet and BSC Testnet.

  • BSC Mainnet, is the main network for production applications. Users are interacting with smart contracts on the Mainnet and thus Mainnet tokens (BNB/BEP20) are actual cryptocurrencies.

BSC Block Explorer

BSC offers block explorer apps for network and on-chain information inquiry, Click to access Testnet Explorer or Mainnet Explorer.

BSC Data Solution

If you’re no longer satisfied with the chain’s speed in sync as a result of scalability limited by native nodes, StreamingFast offers an alternative streaming solution with full history for those who wants to get real-time updates of contracts, account balances, AMM prices or sync their local database, with speed 50x faster than nodes. Available to everyone for free at StreamingFast.io

Faucet

Developers often needs tokens when developing on BSC Testnet to play with contract or to make transactions. BSC Testnet offers Faucet service to acquire free Testnet tokens, of course BSC Studio also integrates Faucet Functionality in the toolbar for easier invocation to faucet tokens.

BSC Smart Contract Development

Key Tools in BSC Development

Truffle Truffle is a development framework based on Solidity that aim to simplifies construction and management process of dApp. Truffle is written in Javascript comes with a powerful set of features to support compilation, deployment and test of smart contracts.

Creating Smart Contract Project

BSC Studio integrates a few smart contract template. You may create your first smart contract project with a corresponding template and start building your smart contract instantly. Built-in templates include:

  • Open Zeppelin: A smart contract offers ERC-20, ETC-721(NFT) tokens, based on Open Zeppelin.
  • MetaCoin: A MetaCoin template based on Truffle.

Contract Deployment and Interaction

BSC Studio offers one-click automated process to

  1. Contract Interaction

Developing a complete dApp

The smart contract we just written is a services running on Binance Smart Chain, it defines a series of on-chain transaction serving the purpose we have set in development. It functions like the backend service in the traditional software practice, so in order to take off the burden of programming, we also need to develop a frontend application to serve as the user interface to the smart contract so that the combination makes a simple, but complete blockchain application, also known as decentralized application or dApp.

  • Configure SDK with BSC RPC interface: Documentation can be found at BSC-RPC
  • Integrate Browser Plugin SDK: such as MetaMask or Binance Chain Wallet
  • Optional Integrate BSC Scan APIs to allow inquiry on-chain data that are not supported by RPC interface (i.e. transaction history, token information)
  • This dApp auto-detect current network (BSC Testnet/Mainnet);
  • If all tests passed, A pop-up windows will show up to request authorization for access;
  • This dApp offers transfer button. Input required information and press Execute button, dApp will invoke pop-up windows through browser plugin where users can sign the transaction to complete it;
  • This dApp provides methods to interact with contract.