Vous êtes sur la page 1sur 4

The guide on how to create a general cryptocurrency using smart contracts.

So, let us start with the basics. WHAT is a cryptocurrency?

A cryptocurrency is a token or asset that is supported by a blockchain. Each blockchain is, in


short, a growing list of records that is secured by cryptography, or hashing. You’ve most likely
heard of bitcoin, Ethereum, and some others by now.

The ERC 20 Smart Contract

Thankfully, Ethereum already has smart contracts built into their network, so instead of having to
create our own cryptocurrency from scratch, we can use the tools that they have provided.
Ethereum has a token standard called “ERC20,” which stands for “Ethereum request for
comments.” The main part of what differentiates these ERC20 tokens from standalone currencies
is that they are integrated into the Ethereum network, and use the hashing transactions that come
with ETH.

ERC20 is closer to a set of rules that defines an Ethereum coin, also known as a token standard.
It allows for developers to program their own functions within the Ethereum network. Many
ERC20 tokens exist already, with more being created every day. You can see the list here:
https://etherscan.io/tokens

Examples of ERC20 contracts:

EOS – probably one of the most notorious and well-known is EOS. At the time of writing, EOS
has the 9th highest market cap of all cryptocurrencies, coming in before big coins such as IOTA,
Dash, and Monero. The decentralized network allows for parallel processing and ICO’s, and
anything else decentralized.

Qtum – a decentralized community that is mobile-friendly. Open-source, and it tries to focus on


building mobile applications. Qtum also tries to “bridge the still existing gap between
blockchains and the business world.”

We’re going to need a few things before you start the project.

1. An Ethereum-blockchain wallet. I suggest either Metamask or MyEtherWallet.


2. Some Ethereum to start out with. I believe that Dr. Liew has prompted you to get some
bitcoin and ethereum, but I would ask him if you have not.
3. A brain full of ideas.
4. [OPTIONAL] A text editor (like notepad++ or sublime)
5. An hour or two.
Steps for installing Metamask:
1. Download the chrome extension “Metamask.” It has the icon of a fox on it.
2. Create an account. Be sure to save the 12 words (I would write them down).
Steps for Creating the ERC-20:

1. Creating the token’s base details.

For the token to work like an ETH-based token, it’s going to need a few variables that you will
create yourself.
1. The name: Call it whatever you want, but I would recommend something on the shorter
side. Naming something easy to remember is a plus.
2. The total supply: This will be the total number of coins in circulation. This means that
whatever you set cannot be added or subtracted (with exceptions).
3. The decimal places. Will this be a coin that can be divided into many pieces? The number
of decimal places will determine how far you can divide it. For example, 1 decimal place
means you can go to 100.1 coins, whereas 2 decimal places will allow you to go to
100.18 coins.
4. The symbol: A nice acronym or shortened name. Ex. Ethereum -> (ETH)

2. Filling in the blanks.

Now I’m going to lovingly borrow* some source code which you can access here.
https://docs.google.com/document/d/1zRGg5bMh944JhPVWcBx_YDK9cJxD3953pCI-
GZ5YLCs/edit?usp=sharing

It’s open-sourced, so anyone can access, use, and improve upon it.

If you scroll towards the bottom, you can see that there is this section of code:

function ERC20Token( ) {
balances[msg.sender] = NUMBER_OF_TOKENS_HERE; // Give the creator all
initial tokens (100000 for example)
totalSupply = NUMBER_OF_TOKENS_HERE; // Update total supply
(100000 for example)
name = "NAME OF YOUR TOKEN HERE"; // Set the name for
display purposes
decimals = 0; // Amount of decimals for display purposes
symbol = "SYM"; // Set the symbol for display purposes
}

Easily enough, you can just fill in the blanks. For the name and symbol, make sure to put the
name in quotations, otherwise it won’t compile properly. Edit what is highlighted in red.

function ERC20Token( ) {
balances[msg.sender] = 1000000; // Give the creator all initial tokens (100000 for
example)
totalSupply = 1000000; // Update total supply (100000 for example)
name = "JoshsCoin"; // Set the name for display purposes
decimals = 1; // Amount of decimals for display purposes
symbol = "JSH"; // Set the symbol for display purposes
}

Next, you should change the function name to be something related to your project. The two
lines below determine the name of the function

contract ERC20Token is StandardToken {

function ERC20Token(

These two lines determine what the function is called, so name them something appropriate.
Make sure that whatever name you put in matches!

Note: For those who want to go above and beyond and are familiar with coding, you can research
functions and implement them yourself. There are many different open-source functions you can
find that do things such as allow for the supply to fluctuate, be compatible with other
blockchains, etc.

3. Testing/Creating the token.


Depending on if you want to test the token on a test-net before you permanently make the coin,
you are given the option to experiment with a test network. In metamask, you are given the
option to pick between which Eth network you are connected to.

3.5 [OPTIONAL] Test network first


If you click on the metamask extension at the top right of chrome, you will be able to change
which network you are on. I used the Ropsten Test Network to create my experimental project.
The benefit of doing this step first is that it does not cost you any money if you make a mistake.
To refill your account with ETH, hit “BUY” and request Ether from the faucet. It’s completely
free, but it can only be used on the test network. Skip to step 5.

4. Real network later


You can send your metamask account the Ethereum you already should have by sending address
shown in the extension some Eth from an account you should already own.

5. Creation and Completion


Go to https://ethereum.github.io/browser-solidity/#optimize=false&version=soljson-
v0.4.19+commit.c4cbbb05.js to publish your script that your wrote as a smart contract.

Copy-and-paste your code into the text field, and then look towards the right where it says
“compile,” “run,” “settings,” and so on. In the settings tab, you will find a text field that lets you
choose your solidity version. Pick the most recent one (0.4.19 at time of writing) that is not a
nightly solidity. Nightly compilers aren’t finished products so it’s best to stay with the releases.
You’re going to want to remember what compiler you used for step 6.
Now go to the “Run” tab and hit “Create.” This should prompt you to pay with Metamask, which
you would accept. If you go back to the metamask extension, you will find that under the “Sent”
tab, there should be a transaction for “Contract Published.” Go to the transaction information,
and copy the address that the contract is being sent to. Keep this page open, it will also come in
handy for step 6. If you go back to the metamask “Tokens” tab, you will be able to add your
token by pasting the address you just copied into the “Token Contract Address.” The info for the
symbol and the decimals should automatically fill out.

And just like that, your very first crypto is born! You can send it to people by going on
MyEtherWallet. Metamask does not currently have a way to send ERC20’s via the extension, so
you can go to https://www.myetherwallet.com and select Metamask as your wallet option. You
can “Add Custom Token” to show your personal token using the contract address from before.

6. Verification
Verification is important, especially when you deal with a legitimate business model.

Go back to the contract creation transaction page. Click on the contract address that you copied
earlier, and go to the “Contract Code” tab. You want to click on “Verify and Publish” in order to
verify your code as being true.

The next screen you’re brought to requires the Contract Address (Filled in), the Contract name,
the compiler, and optimization. The contract name is whatever your function’s name was in the
code. The compiler would be the version that you used in step 5. Turn off optimization. Then,
copy your source code into the text field that says “Enter the Solidity Contract Code below.” The
rest of the text fields you can ignore. If done correctly, your code should be verified.

7. Verified on Etherscan

To verify your coin, you need to go to https://etherscan.io/contactus and select option 4. Once
you fill out the information, you can send it to them and let them verify it. The main 4 elements
you will need are the Contract address, the Official site URL (your own website), a logo, and a
contact email address.

This step is only if you want to go further in making your project grow.

Vous aimerez peut-être aussi