# Issue tokens on the IoTeX Blockchain

IoTeX is fully compliant with ERC20, ERC721 Ethereum token standards, so that you can just port any existing Ethereum token to IoTeX with no change to the code.

XRC20 is the IoTeX equivalent for the ERC20 token standard, while XRC721 is the equivalent for ERC721.

# Issue an ERC20 Token on IoTeX

As a quick example, let's see how to deploy an XRC20 token on IoTeX in a few simple steps:

# 1. Get IoPay Desktop wallet ready

In this example we will use IoPay Desktop wallet to deploy the contract. Download IoPay Desktop wallet from http://iopay.iotex.io/desktop/ (opens new window), create a new account or import a private key if you have one, and select the Test Network from the Network combobox. Finally, get some IOTX test tokens from any IoTeX faucet and send them you your IoPay account address:

Select "Testnet" in IoPay Desktop

# 2. Edit Solidity code in IoTeX Studio IDE

IoTeX Studio is the Web IDE to develop and deploy IoTeX Smart Contracts. It's still an early release, yet it can already compile solidity code and deploy your contracts. The most recent supported Solidity compiler is v0.5.5, so let's use the following example contract from OpenZeppelin to deploy a Simple Token (opens new window).

Open IoTeX Studio at ide.iotex.io (opens new window), delete any existing code in the editor, and paste the following code:

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/GSN/Context.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/token/ERC20/ERC20Detailed.sol";

 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
contract SimpleToken is Context, ERC20, ERC20Detailed {

     * @dev Constructor that gives _msgSender() all of existing tokens.
    constructor () public ERC20Detailed("SimpleToken", "SIM", 18) {
        _mint(_msgSender(), 10000 * (10 ** uint256(decimals())));

This will create a token named SimpleToken, whose symbol will be SIM, plus it will have 18 decimals digits (i.e. it can be fractioned down to 101810^{-18}), and will be pre-mined: 10,000 of SIM tokens will be assigned to the account that is deploying the token contract upon contract deployment to the blockchain. You can customize these values to anything else if you wish!

# 3. Build and Deploy

Make sure the selected version number for the solidity compiler in the Studio is at least v0.5.0, then click COMPILE button to compile your token contract:

Select compiler version then click COMPILE

You are now ready to deploy your token! Select IoPay as the environment you want to deploy to (or choose Javascript to deploy and test interaction in the browser)

Select IoPay as the deploy environment

Now, in the Deploy section select your contract by name (it's SimpleToken, or the name you chose for it), and click DEPLOY button:

Select the token contract and click DEPLOY

check out the logs window at the bottom for the newly deployed contract address, and take note of it!

Select the contract to deploy then click DEPLOY

IoPay desktop will now pop up with a transaction confirmation dialog: confirm it to deploy your contrat to the IoTeX testnet!

Sign the deploy transaction in IoPay

In IoTeX Studio IDE, you can now expand your contract under the "Deployed Contracts" section and test contract calls. For example, you can make a call to the balanceOffunction to query the balance of your IoPay account that deployed the contract:

Check the balance of the contract owner account

# 4. Import your token in IoPay Wallet

You can import any IoTeX token into IoPay wallet, including the token that you just issued, to check your balance, and transfer your tokens to any othe IoTeX Account!

In IoPay Desktop just click the Custom Token link and input the contract address of your token to import it (you obtained it in the IoTeX Studio log window when you deployed the contract).

Import a custom token in IoPay Desktop by the token contract address

Cutom token imported in IoPay

As you will notice, you have a balance of 10,000 SIM: the pre-mined amount that was assigned to the account when you deployed the contract!