How To Create a Token On Cronos

In This Article

Cronos Solidity Development Coding - How To Create A Token On Cronos

How to Create a Token on Cronos Using Remix

Creating a token on the Cronos blockchain can be a rewarding experience, especially if you want to leverage decentralised finance power (DeFi). In this guide, we’ll walk you through creating your own ERC-20 token on the Cronos network using Remix, a popular Ethereum development environment. We’ll start by setting up MetaMask, then connect to the Cronos network, open Remix, write the token contract and finally deploy the token.

Step 1: Set Up MetaMask

Install Metamask Cronos - How To Create A Token On Cronos

Install MetaMask

If you haven’t already, download and install the MetaMask browser extension from MetaMask.io. MetaMask is an indispensable tool for seamless interaction with Ethereum-compatible blockchains, including Cronos, and it’s a key part of our journey.

Connect to Cronos Network

  • Open MetaMask and navigate to Settings > Networks > Add Network.
  • Fill in the following details:
    • Network Name: Cronos Mainnet
    • New RPC URL: https://evm.cronos.org
    • Chain ID: 25
    • Currency Symbol: CRO
    • Block Explorer URL: https://cronoscan.com

Once you’ve entered these details, save the Network and switch to it within MetaMask.

Metamask Cronos Network - How To Create A Token On Cronos

Step 2: Open Remix

Visit Remix

Go to Remix IDE, an online Solidity development environment that makes writing, compiling, and deploying smart contracts easy.

Create a New File

Click on the file icon on the left sidebar, create a new file, and name it MyToken.sol.

Step 3: Write the Token Contract

Here’s a simple ERC-20 token contract using OpenZeppelin’s libraries:

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

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor(address initialOwner)
        ERC20("MyToken", "MTK")
        Ownable(initialOwner)
    {
        _mint(msg.sender, 10000000 * 10 ** decimals());
    }
    
    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }

    function burn(uint256 amount) public {
        _burn(msg.sender, amount);
    }
}
				
			

This contract defines an ERC-20 token named “MyToken” with the symbol “MTK”. It includes minting and burning functionalities, allowing the owner to create and destroy tokens as needed.

OpenZeppelin can be used to preconfigure your smart contract and simplify the process.

Explore our Einstein Contract on GitHub for more ideas on creating your Smart Contract.

Step 4: Compile the Contract

Compile the Contract

Click the “Solidity Compiler” tab on the left sidebar and then “Compile MyToken.sol”. Ensure that the compiler version matches the pragma statement in your contract (in this case, ^0.8.20).

Step 5: Deploy the Contract

Deploy

  • Click the “Deploy & Run Transactions” tab on the left sidebar.
  • Select “Injected Web3” in the Environment dropdown to connect Remix to MetaMask.
  • Ensure that the correct MetaMask account is selected.
  • Select MyToken - contracts/MyToken.sol from the Contract dropdown.
  • Click the “Deploy” button and confirm the transaction in MetaMask.
Contract Deployment Cronos - How To Create A Token On Cronos

Step 6: Verify the Deployment

Check MetaMask

After the deployment, you’ll see the contract address in the Remix console. This address is where your token contract is deployed on the Cronos blockchain.

Add Token to MetaMask

To view your new token in MetaMask, copy the contract address, open MetaMask, click “Add Token,” then “Custom Token,” and paste the contract address. Your token should now appear in your MetaMask wallet.

Step 7: Interact with the Contract

You can interact with your token contract using the deployed contract interface in Remix or through the Cronos blockchain using tools like Cronoscan (https://cronoscan.com/).

Creating a Token on Cronos

Following these steps, you’ve successfully created and deployed an ERC-20 token on the Cronos network using Remix. This guide covered setting up MetaMask, writing a simple token contract, deploying it, and verifying the deployment. With your new token, you can explore various DeFi opportunities or even create decentralized applications.

Remember, the blockchain space is continuously evolving, and staying updated with the latest tools and best practices will ensure your projects remain cutting-edge technology.

Google Rating
4.8
Based on 23 reviews
js_loader