Skip to content

Interacting with Moonbeam Using Remix

Intro diagram

Introduction

Another tool developers can use to interact with Moonbeam is the Remix IDE, one of the most commonly used development environments for smart contracts on Ethereum. It provides a web-based solution to quickly compile and deploy Solidity and Vyper based code to either a local VM or, more interestingly, an external Web3 provider, such as MetaMask. By combining both tools, one can get started very swiftly with Moonbeam.

Deploying a Contract to Moonbeam

To demonstrate how you can leverage Remix to deploy smart contracts to Moonbeam, we will use the following basic contract:

pragma solidity ^0.7.5;

contract SimpleContract{
    string public text;

    constructor(string memory _input) {
        text = _input;
    }
}

Once compiled, we can navigate to the "Deploy & Run Transactions" tab. We need first to set our environment to "Injected Web3." This uses the provider injected by MetaMask, which allows us to deploy contracts to the network it is connected to - in this case, the Moonbase Alpha TestNet.

For this example, we'll be deploying the contract from a funded MetaMask account. You can use our TestNet faucet to fund your account for deployments on Moonbase Alpha. Next, pass in Test Contract as input to our contructor function and hit deploy. A MetaMask pop-up will show the information regarding the transaction, which we'll need to sign by clicking "confirm."

Deploying Contract

Once the transaction is included, the contract appears in the "Deployed Contracts" section on Remix. In there, we can interact with the functions available from our contract.

Interact with Contract

Step-by-step Tutorials

If you are interested in a more detailed step-by-step guide, go to our specific tutorials on using Remix on a Moonbeam development node. The steps can also be adapted to deploy on the Moonbase Alpha TestNet by connecting MetaMask to it.