# Remix: Deploying a Smart Contract

Learn how to deploy a simple Solidity-based smart contract to Majestic StarChain using the Remix in-browser IDE

# Pre-requisite Readings

Remix (opens new window) is an in-browser IDE for Solidity (opens new window) smart contracts. In this guide, we will learn how to deploy a contract to a running Majestic StarChain network through Remix and interact with it.

# Connect Majestic StarChain account to Remix

If you haven’t already, follow the steps in the Metamask guide to import your Majestic StarChain private key into Metamask.

Go to Remix (opens new window). There are some contracts in the File Explorer. Replace these with the source code to Counter.sol below. On the left-most bar, select the Solidity Compiler and compile the contract.

Copy pragma solidity >=0.7.0 <0.9.0; contract Counter { uint256 counter = 0; function add() public { counter++; } function subtract() public { counter--; } function getCounter() public view returns (uint256) { return counter; } }

Next, select the Deploy and Run option. Select Injected Web3 as the Environment. This will open a metamask popup for you to connect your Metamask to Remix. Select Connect to confirm.

You should see your account show up in the left-hand panel.

remix connected to Majestic StarChain

# Deploy and Interact

Now that your account is connected, you are able to deploy the contract. Press the Deploy button. A metamask pop-up will appear asking you to confirm. Confirm the transaction.

Once the contract has been successfully deployed, you will see it show up in the Deployed Contracts section in the left-hand side, as well as a green check in the Remix console showing the transaction details.

deployed contract through remix

Now, you are able to interact with the contract through Remix. For Counter.sol, click add. This will open a Metamask pop-up asking you to confirm. Confirm the transaction. Then, click getCounter to get the count, which should be 1.

interacting with deployed contract through remix