π§ 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.
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.
4. Compile the Smart Contractβ
- Go to the Solidity Compiler tab on the left panel.
- Click Compile HelloCorn.sol.
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.
5. Deploy to Corn Networkβ
- Navigate to the Deploy & Run Transactions tab.
- Select Injected Provider from the Environment dropdown (this will connect Remix to MetaMask).
- 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.
- Select
HelloCorn
from the Contract dropdown. - 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.
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.