Step by step teach you to create your own digital currency (token) for ICO

[ Huixin Cloud ] Regularly update articles for everyone, [ Huixin Cloud ] IT software and hardware project business platform


This article introduces in detail the process of how to create tokens based on Ethereum ERC20 from a technical point of view.

write in front

The tokens mentioned in this article are created using Ethereum smart contracts. Before reading this article, you should have some understanding of Ethereum and smart contracts. If you don’t know it yet, I suggest you read what Ethereum is first.

Token

If you do not pursue a precise definition, a token is a digital currency, and Bitcoin and Ethereum are a token.

Using Ethereum's smart contracts, you can easily write your own tokens, which can represent anything that can be traded, such as points, property, certificates, and more.

Therefore, whether it is for business or learning, many people want to create their own token, first post a picture to see what the created token looks like.


Today we will talk about how to create such a token in detail.

ERC20 Token

Maybe you often see ERC20 and tokens appear together, ERC20 is a token standard defined by Ethereum .

Protocols that we must abide by when implementing tokens, such as specifying the token name, total amount, implementing token transaction functions, etc., can only be supported by the Ethereum wallet if the protocol is supported.

Its interface is as follows:



Briefly explain:

name : token name

symbol: token symbol

decimals: Token decimal places, the smallest unit of tokens, 18 means we can have .00000000000000000001 units of tokens.

totalSupply() : The total amount of issued tokens.

balanceOf(): View the token balance of the corresponding account.

transfer(): Implements a token transaction for sending tokens to the user (from our account).

transferFrom(): Implements transactions between token users.

allowance(): Controls the transaction of tokens, such as tradable accounts and assets.

approve(): The number of tokens the user is allowed to spend.

Write the token contract code

Token contract code:







代码的详细解读,请订阅我的小专栏

部署

在开发测试智能合约时,MetaMaskRemix Solidity IDE是两个非常好用的工具,今天就用他们来完成部署。

安装和配置MetaMask请参考开发、部署第一个去中心化应用,不同的上本文选择了以太坊的测试网络Ropsten,如果你没有余额请点击购买buy,进入的网站可以送一些测试以太币给你,配置好之后,界面应该如下:


浏览器打开Remix Solidity IDE,复制以上源码粘贴上,在右侧选项参考如图的设置:


注意Environment和Account和MetaMask保持一致,然后选择合约TokenERC20,填入你想要的发行量,名称及代号,就可以创建合约了。

这时MetaMask会弹出一个交易确认框,点SUBMIT。待合约部署交易确认之后,复制合约地址。

打开Metamask界面,切换到TOKENS,点添加合约,出现如下对话框:


填入刚刚复制的地址,点ADD,这时你就可以看到你创建的代币了,如图:


哈哈,你已经完成了代币的创建和部署(正式网络和测试网络部署方法一样),可以在Etherscan查询到我们刚刚部署的代币。可以用它进行ICO了,从此走上人生巅峰(玩笑话,不鼓励大家发行无意义的代币)。

代币交易

由于MetaMask插件没有提供代币交易功能,同时考虑到很多人并没有以太坊钱包或是被以太坊钱包网络同步问题折磨,今天我用网页钱包来讲解代币交易。

进入网页钱包地址, 第一次进入有一些安全提示需要用户确认。

进入之后,按照下图进行设置:


连接上之后,如图


需要添加代币,填入代币合约地址。

进行代币转账交易


在接下来的交易确认也,点击确认即可。

交易完成后,可以看到MetaMask中代币余额减少了,如图:


代币交易是不是很简单,只要明白了交易流程,使用其他的钱包也是一样的道理。

参考文档

代币标准

Create your own crypto-currency with ethereum


学好区块链,单笔项目百万+不是梦:

区块链产品经理(点击入驻),能力不够也来混个脸熟

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324877308&siteId=291194637