How To Create Your Own Crypto

Sean
4 min readAug 5, 2021

When people think of crypto they usually don’t think of starting their own. They hear names thrown around like Bitcoin or Ethereum or the ever growing popularity of Doge Coin what was once a meme coin now backed by Elon Musk himself.

There is something to be said about the difference between a cryptocurrency and a token though.

Cryptocurrency vs Token

The two most common blockchain-based digital assets are cryptocurrencies and tokens. The biggest differentiation between the two is that cryptocurrencies have their own blockchains, whereas crypto tokens are built on an existing blockchain.

Creating Your Own Crypto Token

For the purposes of this blog we’ll be exploring how we can create our own token hosted on Ethereum’s blockchain. All this really means is that Ethereum has done the heavy lifting of setting up the verification of our transactions.

Tokens are like membership cards to specific stores since they are built on top of the Ethereum or whatever network. Cryptocurrency’s have their own blockchain and value proposition baked in.

In order to create a token you’ll need to write a little code in Solidity. For anyone whose ever written any JavaScript or Java some of the syntax will look familiar with a few key differences.

Here are a few points regarding ERC20 and Solidity nomenclature:

A public function can be accessed outside of the contract itself

view basically means constant, i.e. the contract’s internal state will not be changed by the function

An event is Solidity’s way of allowing clients e.g. your application frontend to be notified on specific occurrences within the contract

For more info on solidity documentation you can refer here: https://docs.soliditylang.org/en/v0.8.6/

And with that, we begin our journey to creating our own crypto.

Step 1. Wallet & Smart Contract

Download an Ethereum wallet. It is recommended to download Mist the OG Ethereum wallet along with Geth.

What we’re trying to accomplish is the ability to deploy a new contract. This will require us funding our wallets with ETH to pay for gas fee’s or the price to transact.

Once Mist is downloaded and funded you can go to the “Wallets” tab and click “Contracts” leading you to a new tab to then click “Deploy New Contract” and finally “MyToken”.

First we need to define two mapping objects. This is similar to a key/value array in most scripting languages.

contract MyToken {

/* This creates an array with all balances */

mapping (address => uint256) public balanceOf;

mapping(address => mapping (address => uint256)) allowed;

}

This process basically links balances to addresses which are done in Hexadecimal formats that are “public” for anyone to see. (ie: 9e0c2920b457ecb509c45d6a2bad0769)

Step 2. Token Supply

Total amount of tokens to be generated. Minimum value is 1, and maximum 1000000000000000. The code to create this would go underneath the code from above and look something like this:

function MyToken() {

balanceOf[msg.sender] = 1000000;

}

Step 3. Enable Transactions (Sending/Receiving)

In order to use your new smart contract & token you’ll need to set up a function that allows you to send it while making sure there is code written so that you cant send more then you have in your wallet. The solidity contract source code at the bottom should look like this:

/* 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;

}

Step 4. Customizing Your Token

You have the basics set up now but if you’d like to name your token and have a token symbol, etc. then you can add a few more lines of code to truly customize your creation.

/* 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

}

These lines of code are similar to Bitcoin BTC or Ethereum name and ETH symbol.

Step 5. Catalog Transfer Events

This last bit of code will help ETH wallets know when your token is being moved around.

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

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);

}

Step 6. Launch Your Token!

All that’s necessary now is setting a fee, somewhere in the middle of cheap and fast and then enter your wallet password to see your new token. As long as someone has a wallet set up they can receive your new token.

Now making the token worth anything is an entirely different story, but if you’ve gotten this far I’m sure you have some plans of your own. Enjoy your new found powers and don’t forget to refill the ink cartridges on your money printer.

PS: An Alternative for the Lazy Folk

If you don’t have any coding experience but still want to deploy your own token there is still hope. All you’ll need to do is this:

Download Metamask — a crypto wallet built into your browser

Go to https://tokenmint.io/ and pay their fee to create your own token.

Everything that tokenmint.io does can be done with some elbow grease and a dive into the code but if you’d rather a quick way to get up and running they are a good source to utilize.

To the moon!

--

--