Skip to main content

🎧 Deploy with Remix

Remix is an online IDE for writing, testing, and deploying smart contracts. It provides a user-friendly interface and supports deployment to various networks, including Corn’s Maizenet and testnet.

1. Prerequisites​

Ensure you have the following:

  • MetaMask with the Corn Maizenet or testnet network added.
  • Ethereum Account: With sufficient BTCN for gas fees.
warning

Public RPCs are rate limited and not suitable for production environments. For applications with high traffic, it is recommended to run a node locally or use a private RPC provider.

2. Create your Workspace​

Open Remix and create a new workspace by by clicking the three line menu on the top left, next to the Worspaces title and selecting Create Blank (or Using a Template). Here you will be able to add your Solidity contract and add its dependencies.

3. Write the Smart Contract​

In Remix, create a new file by right clicking in the file explorer and selecting New File. Write your Solidity contract. For example:

HelloCorn.sol:

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

contract HelloCorn {
string public greeting = "Welcome to Corn!";

function setGreeting(string calldata _greeting) external {
greeting = _greeting;
}
}

Save the file after writing the code.

Remix code

4. Compile the Smart Contract​

  1. Go to the Solidity Compiler tab on the left panel.
  2. Click Compile HelloCorn.sol.
info

Here you can also select the compiler version on the top and change the EVM version and enable optimization through the Advanced Configurations section.

Ensure there are no errors before proceeding.

Remix compile

5. Deploy to Corn Network​

  1. Navigate to the Deploy & Run Transactions tab.
  2. Select Injected Provider from the Environment dropdown (this will connect Remix to MetaMask).
  3. Choose the Corn Maizenet or testnet network from MetaMask. This is the network where your contract will be deployed and where BTCN will be used for gas fees.
  4. Select HelloCorn from the Contract dropdown.
  5. Click Deploy.

MetaMask will prompt you to confirm the transaction. Approve it, and the contract will be deployed to the Corn Network of your choice.

Remix deploy

6. Verify Deployment​

Once deployed, Remix will display the contract’s address in the Deployed Contracts section. You can also verify the contract on the Corn block explorer.

7. Notes on Remix Development​

  • Testing: Remix’s built-in testing environment allows you to interact with your smart contract before deploying to Corn.
  • Fork deployment: Remix also allows you to deploy to a local fork of Ethereum mainnet which may come handy to manually test and debug your contract.
  • Multiple Features: Remix supports multiple features such as as native debugger, connection with GitHub, a variety of plugins, scripting and many more. Explore the docs here.