Solidity Steps
  • Learning Solidity
  • Step 1
    • 1: Introduction
    • 2: Data Types
    • 3: Functions
    • 4: Control Structures
    • 5: State Variable
    • 6: Local Variables
    • 7: Global Variables
    • 8: View Keyword
    • 9: Pure Keyword
  • STEP 2
    • 10: Immunable Keyword
    • 11: Events
    • 12: Condition
    • 13: While Loop
    • 14: Do While Loop
    • 15: For Loop
    • 16: Required
    • 17: Assert
    • 18: Revert
    • 19: Modifier
  • STEP 3
    • 20: Constructor
    • 21: Mapping
    • 22: Array
    • 23: Enum
    • 24: Structs
    • 25: Data Location
    • 26: Inheritance
    • 27: The Shadowing Effect
    • 28: Super Keyword
    • 29: Visibility
  • STEP 4
    • 30: Interface
    • 31: Abstract Contract
    • 32: Payable
    • 33: Using type()
    • 34: Sending Ether
    • 35: Receive
    • 36: Fallback
    • 37: Call
    • 38: DelegateCall
    • 39: Calling Other Contracts
  • STEP 5
    • 40: Factory Contract
    • 41: Proxy Contract
    • 42: Create2
    • 43: Try and Catch
    • 44: Solidity Library
    • 45: ABI Encoded
    • 46: ABI Decoded
    • 47: Keccak256
    • 48: Function Signature Hash
  • TIPS
    • Tips: Solidity by "Immunable"
    • Tips: Truffle Tutorial
    • Tips: Microblog Dapp
    • Tips: Reentrancy
    • Tips: Slither Tutorial
    • Tips: Remix Tutorial
    • Tips: Hardhat Tutorial
  • CAREER
    • 💲Cover Letter
    • 💲Resume
  • ABOUT
    • Contact me
Powered by GitBook
On this page
  • Remix Tutorial
  • Conclusion
  1. TIPS

Tips: Remix Tutorial

PreviousTips: Slither TutorialNextTips: Hardhat Tutorial

Last updated 2 years ago

Remix Tutorial

This tutorial will provide an introduction to the Remix development environment, and show you how to use it to build simple smart contracts.

  • Setting Up To get started, open the Remix development environment at .

  • Writing The Contract We'll write a simple smart contract that stores an integer. To do this, create a new file in the Remix editor and name it MyContract.sol. Then copy-paste the following code into it:

pragma solidity ^0.8; 
contract MyContract {  
    int myInteger;  
      
    constructor() public {    myInteger = 0;  }   
     
    function setInteger(int _myInteger) public {    
        myInteger = _myInteger;  
    }    
    
    function getInteger() public view returns (int) {
        return myInteger;  
    }
}
  • Compiling The Contract Next, we need to compile the contract. To do this, click the "Compile" tab on the left-hand side and select MyContract.sol from the dropdown. Remix will compile the contract, and you should see a "Success" message in the compile output.

  • Deploying The Contract Now that the contract is compiled, we can deploy it to the Ethereum network. To do this, click the "Run" tab on the left-hand side. Remix will open a new window that allows you to deploy the contract.

Fill in the form with the following details:

  • Environment: Injected Web3

  • Account: Select the account you want to use

  • Gas limit: Leave this as the default Then click the "Deploy" button. Remix will deploy the contract to the Ethereum network, and you should see a "Success" message in the deploy output.

  • Interacting With The Contract Now that the contract is deployed, we can interact with it. To do this, we need to first get the contract's address. This is displayed in the deploy output.

Copy the contract address and then go back to the "Run" tab. Paste the address into the "At Address" field and click the "At Address" button. This will open a new window that allows you to interact with the contract.

Now you can call the functions of the contract, for example, the getInteger function. To do this, click the "getInteger" button, and you should see the value of the myInteger variable in the function output.

You can also set the value of the myInteger variable by calling the setInteger function and passing in a new value. To do this, click the "setInteger" button, enter a new value, and then click the "Submit" button. You should see a "Success" message in the function output.

Conclusion

Congratulations, you have successfully created and deployed your first smart contract using Remix!

remix.ethereum.org