Using Remix
Remix is one of the most popular Ethereum programming environments for smart contracts. And due to ICE's Ethereum compatibility, Remix can be directly used to deploy smart contracts on ICE testnet or ICE development node
This post guides you through the process of creating and deploying smart contracts in ICE node using Remix IDE.
For this process, make sure you meet the following prerequisite requirements:
- Account with funds
- Create a workspace and a file in it named
MyToken.Sol
in root directory.
- Paste following code in
MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, Ownable {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 1000 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
NOTE: This is a mintable ERC20 contract based on openzeppelin. It creates MyToken with symbol ‘MTK’ and initially mints 1000 MTK to the owner of the contract. You can generate this code from OpenZeppelin contract wizard
- Navigate to the solidity compiler from the left side navigation and then click on Compile
MyToken.sol
Remix will download all the openzeppelin dependencies and compiles the contract
- Deploy the contract
- 1.Navigate to the deploy and run transaction tab from left side navigation
- 2.Change the environment to injected web3 from Environment dropdown. This will invoke the metamask extension in your browser. Make sure your metamask is configured to ICE testnet (Arctic) (configure metamask).
- 3.Select the account from metamask and confirm the connection
- 4.From contracts dropdown select MyToken.sol and click on Deploy button
- You will be asked to confirm the transaction through metamak popup , confirm it and wait till it is deployed.
- The contract details will appear under deployed contracts in remix
Hence we deployed ERC20 token using Remix on ICE testnet node