Skip to content

Remix IDE

Overview

Remix IDE is a robust browser-based development environment for smart contracts. This guide will walk you through the essentials of the Polkadot Remix IDE to understand the processes of compiling, developing, and deploying smart contracts on Asset Hub.

Prerequisites

Before getting started, ensure you have:

  • A web browser with MetaMask extension installed
  • Basic understanding of Solidity programming
  • Some WND test tokens to cover transaction fees (easily obtainable from the Polkadot faucet)

Accessing Remix IDE

Navigate to https://remix.polkadot.io/. The interface will load with a default workspace containing sample contracts.

In this interface, you can access a file explorer, edit your code, interact with various plugins for development, and use a terminal.

Creating a New Contract

To create a new contract using the Polkadot Remix IDE, you can follow these steps:

  1. Select the Create a new file button in the contracts folder

  2. Name your file with a .sol extension, in this case, Counter.sol

  3. Write your Solidity code in the editor

    You can use the following code as an example:

    Counter.sol
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;
    
    contract Counter {
        int256 private count;
    
        function increment() public {
            count += 1;
        }
    
        function decrement() public {
            count -= 1;
        }
    
        function getCount() public view returns (int256) {
            return count;
        }
    }
    

Compiling Your Contract

  1. To compile your contract, you need to:

    1. Navigate to the Solidity Compiler tab (third icon in the left sidebar)
    2. Select Compile or use Ctrl+S

      Note

      Compilation errors and warnings appear in the terminal panel at the bottom of the screen.

  2. After compiling your contract, you can navigate to the File Explorer tab (first icon in the left sidebar) and check that:

    1. The artifact folder is present
    2. The Counter_metadata.json and the Counter.json files have been generated

Deploying Contracts

  1. To deploy your contract, you need to:

    1. Navigate to the Deploy & Run Transactions tab (fourth icon in the left sidebar)
    2. Select your deployment environment, in this case, Westend Testnet - MetaMask
    3. Click the Deploy and Confirm button

  2. Once your contract is deployed successfully, you will see the following output in the Remix terminal:

Interacting with Contracts

Once deployed, your contract appears in the Deployed/Unpinned Contracts section:

  1. Expand the contract to view available methods

    Tip

    Pin your frequently used contracts to the Pinned Contracts section for easy access.

  2. To interact with the contract, you can select any of the exposed methods

    In this way, you can interact with your deployed contract by reading its state or writing to it. The button color indicates the type of interaction available:

    • Red - modifies state and is payable
    • Orange - modifies state only
    • Blue - reads state

Where to Go Next

The Polkadot Remix IDE offers an environment for developing, compiling, and deploying smart contracts on Asset Hub. Its intuitive interface allows developers to easily write Solidity code, compile contracts, and interact with them directly in the browser.

Explore more about smart contracts through these resources:

  • Guide Smart Contracts on Polkadot


    Dive into advanced smart contract concepts.

    Get Started

  • External OpenZeppelin Contracts


    Test your skills by deploying a simple contracts with prebuilt templates.

    Get Started

Last update: March 6, 2025
| Created: March 6, 2025