After you go through this guide, you will learn how to create an ERC223 token on Ethereum Classic blockchain and an ICO for this token.
How to create a token and ICO on Ethereum Classic Compatible with Saturn Exchange
Note that your created token will be listable immediately on our exchange.
Prerequisites
- Install Saturn Wallet.
- You are ready!
Instructions
- Make sure Saturn Wallet is installed, activated, and pointed to Ethereum Classic network.
- Make sure your Saturn Wallet account has at least 0.1 ETC to pay for gas fees.
- Open this link.
Customize token creation template
When you load up the page from step 3 in instructions you will open up REMIX. Remix is a tool developed by Ethereum Foundation, and is a dApp that lets developers make new dApps. With Saturn Wallet it is now possible to use it on Ethereum Classic network.
Click on gist/YourNewToken.sol
in the top-left corner of the screen to start customizing your token. Treat ERC223.sol
and SafeMath.sol
as libraries that you simply import, written by professional developers - read them if it interests you, or simply ignore those two files.
Let's look at YourNewToken.sol
in more detail. You will need to edit this file in order to create and publish a new token.
These lines describe what compiler version to use and import the necessary libraries. Leave these unchanged.
pragma solidity ^0.4.24;
import "./ERC223.sol";
import "./SafeMath.sol";
Here, do as the comments tell you - change contract name from YourNewToken
to something that better describes your project. Leave the line about SafeMath
unchanged! If you don't use this library, bad things can happen.
// change contract name to your contract's name
// i.e. "contract Bitcoin is ERC223Token"
contract YourNewToken is ERC223Token {
using SafeMath for uint256;
This is where your token is really configured. Hopefully by the time you decided to read this guide you have already come up with a name, symbol, desired total supply and number of decimals.
// for example, "Bitcoin"
string public name = "Token Full Name";
// for example, "BTC"
string public symbol = "TKN";
// set token's precision
// pick any number from 0 to 18
// for example, 4 decimal points means that
// smallest token unit will be 0.0001 TKN
uint public decimals = 4;
// total supply of the token
// for example, for Bitcoin it would be 21000000
uint public totalSupply = 1000000000 * (10**decimals);
Next comes ICO configuration. You will be able to set treasury
address and the price. Treasury is the address where incoming ETC will be forwarded. This can be your Saturn Wallet address, a paper wallet or a Ledger Nano.
The price is unfortunately not quite intuitive because of how Solidity, the smart contract language used by Ethereum Classic, works. When the smart contract receives Ether (ETC) it is denominated in wei (1 ETC = 1000000000000000000 wei, use this calculator to make the conversion). You also need to take the amount of decimals of your token into account.
address private treasury = 0x23cc32A2f2Cf1477E7AA43774663f7f96e3B8F99;
// ICO price. You will need to do a little bit of math to figure it out
// given 4 decimals, this setting means "1 ETC = 50,000 TKN"
uint256 private priceDiv = 2000000000;
We also declare a Purchase
event in case one wants to build a dApp for the ICO later. Just leave this line as is.
event Purchase(address indexed purchaser, uint256 amount);
Constructor is the piece of code that runs once on contract creation. This is a good place for initialization. In the token's constructor we need to assign initial balances. In this example, we give 85% of tokens to the creator's account (your Saturn Wallet address), and 15% is allocated for ICO. Change these numbers for your token as you see fit.
constructor() public {
// This is how many tokens you want to allocate to yourself
balances[msg.sender] = 850000000 * (10**decimals);
// This is how many tokens you want to allocate for ICO
balances[0x0] = 150000000 * (10**decimals);
}
This is the function that handles incoming ETC transfer. Feel free to read through it but do not change it.
function () public payable {
bytes memory empty;
if (msg.value == 0) { revert(); }
uint256 purchasedAmount = msg.value.div(priceDiv);
if (purchasedAmount == 0) { revert(); } // not enough ETC sent
if (purchasedAmount > balances[0x0]) { revert(); } // too much ETC sent
treasury.transfer(msg.value);
balances[0x0] = balances[0x0].sub(purchasedAmount);
balances[msg.sender] = balances[msg.sender].add(purchasedAmount);
emit Transfer(0x0, msg.sender, purchasedAmount);
emit ERC223Transfer(0x0, msg.sender, purchasedAmount, empty);
emit Purchase(msg.sender, purchasedAmount);
}
}
Deploying your token and ICO to Ethereum Classic network
Click Start to compile
in the top right corner and then switch to the Run
tab.
Select the right contract in the dropdown menu and hit the red Deploy
button! A scary looking popup will appear - just scroll down and click Confirm
. Saturn Wallet will ask you to sign the transaction, click Submit
.
Congratulations!
You have successfully deployed your first token and an ICO on Ethereum Classic network.