How to Develop Smart Contract on Remix IDE?

Follow the steps below to develop a smart contract on Remix IDE:

Step 1: Open the Remix IDE and click on the File Explorer.

Step 2: Select create a new workspace option from the drop-down menu.

create a new workspace

Step 3: Enter the name of the new workspace w3wiki.

New workspace

Step 4: In the workspace w3wiki, right-click on the option contracts and select the option New File.

Create New File

Step 5: Create a new file Bank.sol.

Bank.sol

Step 6: Paste the below code in Bank.sol.

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

contract Bank
{
    address Owner;

    // Creating the Mapping for the Adding & 
    // Transfer Amount in Account
    mapping(address=>uint)Balance;

    // Constructor for the address of the Owner
    constructor()
    {
        Owner = msg.sender;
    }
    

    // Function for adding the Ethereum in Account
    function depositBalance(uint amount) public returns(uint)
    {
        // First check whether it is Owner's Account or Not
        require(msg.sender == Owner, "This is Owner's Account !!");
        Balance[msg.sender] = Balance[msg.sender] + amount;

        return Balance[msg.sender];
    }

    // Function to Get the Balance from an Account
    function displayBalance() public view returns(uint)
    {
        return Balance[msg.sender];
    }

    // Function to transfer the Amount from Owner to Recipient
    function Transfer(address recipient, uint amount) public
    {
        // Function to check the Self account is or not
        require(msg.sender != recipient, "Can't Transfer !! Self Account.");

        // Function to check the owner has balance is available or not
        require(Balance[msg.sender] >= amount, "Insufficient Balance !!");

        _transfer(msg.sender, recipient, amount);
    }

    function _transfer(address From, address To, uint Amount) private
    {
        Balance[From] = Balance[From] - Amount;
        Balance[To] = Balance[To] + Amount;
    }
}

Explanation:

There are 4 functions in the smart contract Bank.sol:

  1. depositBalance()
    • require(msg.sender == Owner, “This is Owner’s Account !!”) : Address is checked to determine if it is owner’s address or not.
    • Balance[msg.sender] = Balance[msg.sender] + amount : Amount is added to the available balance in the account.
  2. transfer()
    • require(msg.sender != recipient, “Can’t Transfer !! Self Account.”) : This checks recipient address against sender’s address, if the address is matching a message is displayed “Can’t Transfer !! Self Account”.
    • require(Balance[msg.sender] >= amount, “Insufficient Balance !!”) : This checks whether the requested amount is less than the available balance or not. If not, then a message is displayed “Insufficient Balance”.
    • _transfer(msg.sender, recipient, amount): If recipient address is correct and balance is available then _transfer() function is invoked.
  3. _transfer()
    • Balance[From] = Balance[From] – Amount: Balance is deducted from sender’s account.
    • Balance[To] = Balance[To] + Amount: Balance is added to recipient’s account.
  4. displayBalance()
    • return Balance[msg.sender]: This will display sender’s account balance.

Steps to Create, Test and Deploy Ethereum Smart Contract

Smart contracts are self-execution programs stored on a blockchain that are automatically executed when predefined conditions are met. They allow the participants on the blockchain to transact with each other without a trusted central authority. After creating a smart contract, the next step is to deploy the smart contract onto a blockchain for execution. For this purpose, developers often use development tools such as Remix IDE. This article focuses on discussing steps to create, test, and deploy the Ethereum Smart Contract on Remix Tool.

Table of Content

  • What is Remix IDE?
  • Getting Started With Remix IDE
  • What is Solidity Programming Language?
  • How to Develop Smart Contract on Remix IDE?
  • Steps to Compile the Smart Contract
  • Steps to Deploy the Smart Contract
  • Conclusion
  • Frequently Asked Questions related to Steps to Create, Test and Deploy Ethereum Smart Contract

Similar Reads

What is Remix IDE?

Remix IDE is a no-setup tool with a GUI that is used for smart contract development. It is famous for the visual debugger and allows for a simple deployment process....

Getting Started With Remix IDE

Step 1: Open the Remix IDE in your browser following the URL https://remix.ethereum.org/. You will be presented to the following screen:...

What is Solidity Programming Language?

Solidity is a statically typed programming language that is designed for developing smart contracts that run on Ethereum....

How to Develop Smart Contract on Remix IDE?

Follow the steps below to develop a smart contract on Remix IDE:...

Steps to Compile the Smart Contract

Smart Contact can be Compiled by two methods:...

Steps to Deploy the Smart Contract

Follow the step below to execute the code after successful compilation:...

Working of Deployed Smart Contract

After deploying the code, click on the method button under the drop-down of deployed contracts to invoke the method, and for the output scroll down to see the result....

Conclusion

Writing and deploying smart contracts may seem challenging but with the right development tools and knowledge, it can be a simple process. In this article, we have walked through the process of using Remix IDE for developing and deploying the smart contract. By following the step-by-step guide, one can start building a smart contract and harness the power of Blockchain Technology....

Frequently Asked Questions related to Steps to Create, Test and Deploy Ethereum Smart Contract

What is the limit of smart contract in Ethereum?...

Contact Us