DEV Community

Cover image for Getting Started with Smart Contracts on Ethereum using Remix and Metamask
Shish Singh
Shish Singh

Posted on • Updated on

Getting Started with Smart Contracts on Ethereum using Remix and Metamask

If you're new to blockchain development and want to create your own smart contracts on the Ethereum blockchain, you're in the right place. In this step-by-step guide, we'll walk you through the process of writing and deploying a simple smart contract using Remix and interacting with it using the Metamask Test Wallet.


A basic understanding of Ethereum and smart contracts.
Google Chrome browser installed.
A stable internet connection.

Step 1: Setting Up Metamask

Metamask is a popular Ethereum wallet extension for browsers. Follow these steps to set up Metamask with a test wallet:

a. Install Metamask Extension:

Open your Google Chrome browser.
Go to the Chrome Web Store.
Search for "Metamask" and click on "Add to Chrome."
Click "Add Extension" in the confirmation popup.
The Metamask icon should now appear in your browser toolbar.

b. Create a Test Wallet:

Click on the Metamask icon in your toolbar.
Click "Get Started."
Select "Create a Wallet" and set a strong password.
Follow the prompts to save your secret backup phrase securely.
Congratulations! Your Metamask test wallet is ready.

c. Fund Your Test Wallet:

To get test Ether for your wallet, you can use services like Alchemy Faucet.

Step 2: Writing Your Smart Contract

Now, let's write a simple smart contract using Remix, an online Solidity code editor and compiler.

a. Open Remix:

Visit in your browser.
You'll see Remix's interface with different panels. In the "File Explorers" panel, click on the "+" button next to "contracts" to create a new file.
Name your file "SimpleContract.sol" and click "OK."

b. Writing the Smart Contract:

Copy and paste the following code into the "SimpleContract.sol" file:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

contract SimpleContract {
    string public message;

    constructor() {
        message = "Hello, Ethereum!";

    function updateMessage(string memory newMessage) public {
        message = newMessage;

Enter fullscreen mode Exit fullscreen mode

Here's a breakdown of this simple contract:

  • pragma solidity ^0.8.0;: This line specifies the compiler version.

  • contract SimpleContract { ... }: This defines the main structure of the contract.

  • string public message;: Declares a public state variable called "message" of type string.

  • constructor() { ... }: The constructor function initialises the "message" variable with the default message.

  • function updateMessage(string memory newMessage) public { ... }: This function allows you to update the "message" variable with a new string.

Step 3: Compile and Deploy the Contract

  • In the "Solidity Compiler" panel, select "SimpleContract.sol" from the dropdown.

  • Click the "Compile SimpleContract.sol" button.

  • In the "Deploy & Run Transactions" panel, select "Injected Web3" in the Environment dropdown (Metamask integration).

  • Click the "Deploy" button. Metamask will ask for confirmation; click "Confirm."

Step 4: Interacting with Your Smart Contract

  • In the "Deployed Contracts" section, you'll see your deployed contract.

  • Expand it to see the contract functions.

  • Click "updateMessage."

  • Enter a new message (e.g., "Hello, Remix!").

  • Click "transact."

  • Metamask will open, requesting confirmation for the transaction. Click "Confirm."

Congratulations! You've successfully written, deployed, and interacted with your first Ethereum smart contract using Remix and Metamask. You've also set up a Metamask test wallet through Alchemy Faucet and added the Metamask extension to your Chrome browser.

Feel free to explore more complex smart contracts and continue your journey into Ethereum development.




Check out my other blogs:
Travel/Geo Blogs
Subscribe to my channel:
Youtube Channel
Destination Hideout

Top comments (0)