Deploy a token in Remix IDE
The easiest way to deploy an XRC20 token on IoTeX is using Remix IDE in conjunction with Metamask. We will deploy the reference implementation from Openzeppelin of a preset ERC20 token with fixed supply and burnable.
Hints for first timers 👇
If this is your first smart contract deployment, and you're not really sure where to start from, or if you maybe find some of the following concepts unclear, these are some useful links to official resources: 1) Intro to Ethereum Smart Contracts 2) Intro to Smart Contracts Deployment 3) Intro to Development Frameworks
Please note that in this section we'll make use of OpenZeppelin, "a platform to develop, deploy and operate smart contract projects on Ethereum and every other EVM and eWASM-powered blockchain". OpenZeppelin also offers a whole set of community audited smart contracts. You can check out their GitHub repository here.
Once deployment is done, you might want to think about registering your token and including it in the IoTeX Ecosystem tools such as the block explorer and the official ioPay wallets. You can learn all about registering your token here.
1. Configure Metamask
Make sure you configured Metamask for use with the IoTeX Blockchain and that the IoTeX network, whether its mainnet or testnet, is actually selected in Metamask:
pageMetamask Wallet2. The source code
We will deploy the token contract defined in the contract below, which is taken from the Openzeppelin preset ERC20PresetFixedSupply.sol with a minor change to the import statement required to access the Openzeppelin files over the web and allow the compilation in a Web IDE:
Open Remix IDE and paste the code
Open the Remix IDE and create a new file under the Contracts
folder: call it Simpletoken.sol
and paste the source code of the token, then save the file:
3. Compile the contract
Move to the "Solidity Compiler" tab in the left navigator, select the correct compiler version as required by the pragma
directive in the contract, then compile:
Deploy the contract
Switch to the "Deploy & Run Transactions" tab, select "Injected Web3" as the environment to make Remix use your Metamask account as a signer.
Next to the "Deploy" button, you must fill in the required constructor arguments which are:
Token name: "Simple Token"
Token symbol: "SIM"
Total Supply (in Rau): 1000000000000000000000000 (1 Million tokens)
Address: the contract owner address, which will also receive the whole supply upon deployment
So this is how your Deploy arguments field should look like:
Finally, hit "Deploy" and confirm the deployment transaction in Metamask (make sure you have some IOTX to pay for gas in your Metamask wallet!
Interact with the Contract
Once the contract is deployed, you can easily interact with it directly in the Remix UI. For example, you can query the balance of the contract creator address, which should have received the entire total supply of the token upon deployment.
Look for the "SimpleToken" deployed contract in the left panel and expand it. Input the address you used to deploy the contract in the arguments field of the "balanceOf
" function, click the "balanceOf
" button to actually execute the contract call, and you should see the balance of SIM for your account right below the button:
Last updated