Chain IDE For BSC Tutorial

2021.2.8  •  2 min read
Blog post image.


Introduction

ChainIDE is one of the largest online Integrated Development Environment for smart contracts in the world. It can support multi-chain online compilation, deployment, contract interaction, and other functions. This tutorial provides about how to compile and deploy the smart contract on Binance Smart Chain testnet using ChainIDE and Metamask.

Requirements

  1. Configure your MetaMask for Binance Smart Chaintestnet: If you haven’t set up your MetaMask, please follow the steps in this blog
  2. Get testnet fund : you can get some BNB or BEP20 tokens from this page. For working with mainnet or testnet Binance Smart Chain, you normally need the BNB token, similar to working with ETH on the Ethereum blockchain. When you deploy smart contracts, you’ll need to deploy them with BNB.

Getting Started

Now that you have you everything set up, go ahead and deploy a demo solidity contract to get price feed from Band Protocol.

Create a new Project

Go tobscide.com, click the directory bar in the upper left corner, and then click on “Create project”.

Create Smart Contract

The contract code below demonstrates a simple usage of the new `StdReference` contract and the `getReferenceData` function. https://gist.github.com/huangsuyu/0c20226411047d5aa2a21450d461f59d

Band Oracle is updated every 5 minutes.

Compile Your Contract

click Compile `band.sol` on the right to compile the solidity file. After the compilation is successful, the following ABI and bytecode content will appear, and `Compile contract success` will be output on the console.

Deploy Your Contract

Now that everything is set up, we can deploy and read from our IDE. Click at “Deployment & Interaction” on the right to enter the deployment page, set the gas limit (1000000) and gas fee (20 Gwei), and then click Deploy and confirm on Metamask.

The ref address for constrction is `0xDA7a001b254CD22e46d3eAB04d937489c93174C3`

Confirm your deployment in MetaMask

Interact with Your Contract

Finally, we have to interact with the contract deployed on the chain to obtain our own wallet address. Click interact-Storage-getAddress to open, and then click commit to interact with the contract.

For example, get the current BNB price.

Congratulations! You have successfully deployed your first contract with Chain IDE.

Need more help?

Tap the community for troubleshooting help in TG group: https://t.me/joinchat/GKXPkbNCoKLCxixP

Share