Skip to main content

Using Replit IDE for Deploying Smart Contracts on BSC

Replit is a coding platform that allows you to write code and host apps. Replit supports Solidity programming language and provides all of the features and functionality that are required by Web3 developers for creating and deploying smart contracts.

In this tutorial, we explain how to build and deploy a solidity smart contract on the BSC Testnet using the Replit IDE and the Replit Solidity Template (Solidity starter beta)

note

For additional examples about Solidity with Replit, you can read the article Get started with Replit! or check Replit Solidity documentation and Escrow contract tutorial

Pre-Requisites​

There is no need for any local environment settings for deploying solidity smart contracts on BSC using Replit.

All you require is a browser-based Web3 wallet (e.g. MetaMask) to interact with the BSC Testnet and deployed contracts. If you are already using MetaMask, it is recommended to create a new account for testing with Replit. You can do this from the account menu, which appears when you click on the account avatar in the top right corner of MetaMask interface.

You must set up all of the following Pre-requisites to be able to deploy your solidity smart contract on BSC:

  1. Create a Replit account
  2. Download Metamask wallet
  3. Configure BNB Smart Chain Testnet on Metamask
  4. Get BNB testnet tokens

Working with a Repl​

Every Repl that you create is a fully functional development and production environment. Follow the steps to create a solidity starter Repl:

  1. Login or create an account. After creating your Replit account, your home screen will include a dashboard where you can view, create projects, and manage your account.
  2. Once logged in, create a Solidity starter repl, Select + Create Repl from the left panel or + in the top right corner of the screen.
  3. Select the Solidity starter (beta) template and specify a title for your project.
  4. Click on + Create Repl for creating your project.

Note The Solidity starter repl comes with a friendly web interface, built using the Web3 Ethereum JavaScript API, which you can use to deploy and interact with your smart contracts. For this tutorial, we will deploy smart contract on to BNB Smart Chain Testnet.

Create Smart Contract​

Delete the contents of the contract.sol file and paste the following solidity code into this file.

// SPDX-License-Identifier: MIT
pragma solidity >0.4.0 <= 0.9.0;

contract HelloWorld{
function sayHello() public pure returns (string memory) {
return "Hello, World!";
}
}

Deploy on BSC​

Make sure that you have followed the list of Pre-requisites above so that you are ready to deploy and interact with your smart contract:

  1. Click on Run (at the Top) to install all relevant packages and start up the contract deployment UI.
  2. Click on image icon to open the web interface for deloyment in a new browser tab.
  3. Connect your MetaMask wallet to the web interface and switch to the BSC Testnet.
  4. Click on Connect wallet, select your account, then choose Connect.

image

image

  1. From the Drop-down list, Select the contract that you want to deploy. Click on Deploy.

image

  1. Approve the MetaMask notification that appears asking for confirmation of the transaction from your wallet to deploy the smart contract.

image

  1. Copy the address of the deployed contract.

image

  1. Navigate to BscScan Testnet Explorer to search and view your deployed contract. Using the contract address to search for it.

image

Once your contract has been deployed, it will show up as expandable boxes below the drop-down box. Expand it and take a look at all the different functions available. You can now interact with your contract using the provided user interface or from a sharable URL shown on the interface.

image

Publish to Replit​​

Replit allows you to publish your projects to a personal profile. After publishing, projects will show up on your spotlight page for others to explore, interact with, clone, and collaborate.

See Publish your Repl.

Conclusion​

This tutorial guided you through the basics of creating and deploying a smart contract using the Replit IDE. We also provided steps on how to interact with the deployed contract online and publish your replit project. This tutorial uses testnet, however, the exact same instructions and sequence will work on the mainnet as well.