Smart Contracts With Remix IDE


Preparations

  1. Installed the MetaMask and created a account.
  2. Added the Goerli testnet in MetaMask.
  3. Obtained the Goerli’s ETH.

Remix IDE

remix.ethereum.org

Quickly Create a Smart Contracts Via Remix IDE

❖ First connect to remix.ethereum.org website.
❖ Create an empty workspace.
remix.ethereum.org
❖ Create a New File "HelloWorld.sol"(.prettierrc.json can delete it).
remix.ethereum.org
❖ Enter the following code in "HelloWorld.sol" file.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract HelloWorldToken is ERC20, Ownable {
    constructor() ERC20("HelloWorldToken", "HWTK") {
        _mint(msg.sender, 1000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}
er20 code 1
❖ Compile "HelloWorld.sol".
❖ After the compilation is complete, you will get a ✅.
remix.ethereum.org
remix.ethereum.org

Deploy & Run Transaction

❖ Login MetaMask and select Goerli test network.
metamask
❖ Select Deploy & Run Transaction in Remix IDE.
❖ Select Injected Provider - MetaMask in ENVPONMENT.
deploy
❖ Deploy and Confirm (will pop up a MetaMask Notification window).
deploy
❖ When you finish Deploy, you will see the contract information in the Deployed Contracts field.
❖ When you want to import tokens, you need to copy the token contract address of HelloWorld first.
deploy
❖ Paste the copied HelloWorld's contract address into the Token contract address field and select "Add custom token" and "Import tokens".
tokens
tokens
❖ Completing HWTK's Smart Contracts.
tokens