BTC iconBTC: N/AETH iconETH: N/ASOL iconSOL: N/ABNB iconBNB: N/ATON iconTON: N/A

Create and Launch Cryptocurrency Token using Solidity and the Remix

Jun 12, 20253 min read
Create and Launch Cryptocurrency Token using Solidity and the Remix

What You'll Need

MetaMask Wallet: A browser extension wallet for managing your crypto and interacting with applications.

Remix IDE: A free, web-based tool for writing, compiling, and deploying smart contracts. No installation is needed.

Step 1: Write the Smart Contract
First, you'll write the code for your token. We'll use the industry-standard OpenZeppelin library to make this simple and secure.
Open the Remix IDE.
In the File Explorers tab, create a new file and name it MyToken.sol.
Paste the following code into the file. This code creates a standard ERC20 token and mints an initial supply for you.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.2;

contract ERC20 {
    mapping(address => uint256) public balances;
    mapping(address => mapping(address => uint256)) public allowed;

    uint256 public totalSupply;
    string public name;
    string public symbol;
    uint256 public decimals = 18;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    constructor(string memory _name, string memory _symbol, uint256 _supply) {
        name = _name;
        symbol = _symbol;
        totalSupply = _supply * (10 ** decimals);
        balances[msg.sender] = totalSupply;
    }

    function transfer(address to, uint256 value) public {
        require(balances[msg.sender] >= value, "Insufficient balance");
        balances[msg.sender] -= value;
        balances[to] += value;
        emit Transfer(msg.sender, to, value);
    }

    function approve(address spender, uint256 value) public {
        allowed[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
    }

    function transferFrom(address from, address to, uint256 value) public {
        require(balances[from] >= value, "Insufficient balance");
        require(allowed[from][msg.sender] >= value, "Allowance exceeded");
        balances[from] -= value;
        balances[to] += value;
        allowed[from][msg.sender] -= value;
        emit Transfer(from, to, value);
    }

    function balanceOf(address owner) public view returns (uint256) {
        return balances[owner];
    }

    function allowance(address owner, address spender) public view returns (uint256) {
        return allowed[owner][spender];
    }
}

Step 2: Compile the Contract

1. Go to the Solidity Compiler tab in Remix.

2. Select the appropriate compiler version (e.g., 0.8.2).

3. Click Compile MyToken.sol.

4. Ensure there are no errors in the compilation process.

Step 3: Deploy the Contract

1. Go to the Deploy & Run Transactions tab in Remix.

2. Select the environment (e.g., Injected Web3 to connect to Metamask).

3. Choose the MyToken contract from the dropdown menu.

4. Fill with your token name, token code, and the supply.

5. Click Deploy.

6. Confirm the transaction in Metamask.

Step 4: Interact with the Token

1. Once deployed, you can interact with the token using the functions provided in the contract:

- transfer: Send tokens to another address.

- balanceOf: Check the balance of an address.

- approve and transferFrom: Allow another address to spend tokens on your behalf.

2. Use the Remix interface to call these functions by entering the required parameters and clicking the respective buttons.

Share this article: