To get started creating your own token on Ethereum, download Mist, an Ethereum wallet that also lets you mine or develop Ethereum software, such as an ERC20 token.
Once you’ve downloaded and opened Mist, fund it with ETH by going to the “WALLETS” tab, click the “CONTRACTS” tab then click “Deploy New Contract”. Where it says “Select Contract to Deploy” click the dropdown menu and select “MyToken.”
Then, enter this code in the Solidity Contract Source Code field that shows up:
contract MyToken {
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
}
“Mapping” in this instance links balances to addresses, which are in hexadecimal format (the uint256 part - e.g. 0xab7c74abC0C4d48d1bdad5DCB26153FC8780f83E). “Public” means that anyone will be able to see other address’ token balances.
Under the code from above, add this to set a limit on the amount of tokens you will create:
function MyToken() {
balanceOf[msg.sender] = 1000000;
}
In the above example, the token supply is 1 million. However, you can of course set this to any number you like.
Enable sending of your token
/* Send coins */
function transfer(address _to, uint256 _value) {
/* Check if sender has balance and for overflows */
require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >=
balanceOf[_to]);
/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
}
For some final touches add this code:
/* Initializes contract with initial supply tokens to the creator of the contract */
function MyToken(uint256 initialSupply, string tokenName, string tokenSymbol, uint8 decimalUnits) {
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
decimals = decimalUnits; // Amount of decimals for display purposes
}
It should be fairly self-explanatory but change tokenName, tokenSymbol, and decimalUnits to change your token’s name e.g. Bitcoin, token symbol e.g. BTC, and decimal places e.g. Bitcoin has 8 decimal places.
Also, add this code to the transfer function from step 3:
/* Notify anyone listening that this transfer took place */
Transfer(msg.sender, _to, _value);
Full transfer function including transfer notification code:
/* Send coins */
function transfer(address _to, uint256 _value) {
/* Check if sender has balance and for overflows */
require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]);
/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
/* Notify anyone listening that this transfer took place */
Transfer(msg.sender, _to, _value);
}
6. Release your token to the world!
The big moment you’ve been waiting for - launching your token!
Set a fee to send your token contract transaction (we recommend a fee ~the middle between CHEAPER and FASTER unless you are in an extreme hurry to launch your token). Click Send and enter your wallet password if necessary before launching your ERC20 token!
Once your token is live, you can go to the Send tab of Mist and send your token to whoever you want. The power to create money is cool, isn’t it?