当前位置:网站首页>智能合约:发布一种ERC20代币
智能合约:发布一种ERC20代币
2022-07-24 04:13:00 【FINGER_NFT】
“一个智能合约是一套以数字形式定义的承诺(commitment),包括合约参与方可以在上面执行这些承诺的协议。”
——尼克·萨博(Nick Szabo)
众所周知,智能合约是区块链区块链中很重要的一部分,代币、交易、质押等等活动都需要智能合约的帮助。
今天,我们就来使用智能合约发布一种ERC20代币。
PS:上手需要知晓钱包、公链的知识
我们先在github上下载代码:https://github.com/fingerchar/fingernft

这是一个开源的NFT交易平台的完整代码,我们只需要其中的代币合约源码就行了。
下载完成,现在我们使用编译器打开代币合约源码 token-contract 文件。

下面是主要文件说明:
- contracts: 存放合约源码。
- script/config.js: 合约部署的配置文件。
- script/deploy.js: 合约部署的启动文件。
先来看看Token.sol,这是代币的定义文件,看起来很简洁吧,只有一个铸造函数,其他都是引用协议标准就行了

接下来是配置文件config.js,让我来一一介绍下这些配置参数:

- privateKey: 钱包私钥地址,它具有钱包的所有权限,千万不能泄露哦。
- chainId: 链ID,你想要将合约部署到那条链,就填相应的链ID。
- apiUrl: 网络访问节点,每个链都有自己的网络访问节点,都是公开的。
- name: 这个合约的名称。
- symbol: 符号,你希望你发布的代币的符号(类似ETH、BNB)。
- supply: 代币的发行量,发布后钱包地址中就会有这个数量的代币了。
最后的启动文件已经写好了,不需要修改了。

打开终端,下载依赖:npm install

下载完成后,就可以部署上链,发布代币了:node script/deploy.js

部署完成后,会生成一个以钱包地址命名的文件,里面存放着你的代币地址

在钱包内导入代币就可以看到刚刚发行的代币了。

整理不易,期待点赞交流哦~~
边栏推荐
- Preliminary use of swagger2
- adobe PR2022 没有开放式字幕怎么办?
- Mitsubishi Ethernet module Yuanchuang intelligent control yc8000-fx connection MCGS operation method
- Histone research -- Characteristics and literature references of histones in Worthington calf thymus
- PAT甲级 1040 Longest Symmetric String
- 1.7.1 正误问题(中缀表达式)
- D2DEngine食用教程(3)———将渲染目标导出为图像文件
- How to configure Ethernet network topology in canoe network based access mode
- Redis sentinel mode, master node check script
- Vscode configuration user code snippet
猜你喜欢

iPhone手机绑定163邮箱解决方案

swagger2的初步使用

Pat class a 1040 long symmetric string

Alibaba Taobao Department interview question: how does redis realize inventory deduction and prevent oversold?

Worthington: characteristics and other parameters of hexokinase from yeast

Opening soon | openatom openharmony sub forum of 2022 open atom global open source summit "interconnection of all things, enabling thousands of industries"

002_ Kubernetes installation configuration

Codeforces Round #808 (Div. 2) A - D

Post it notes --46{hbuildx connect to night God simulator}

Live broadcast preview | practice sharing of opengauss' autonomous operation and maintenance platform dbmind
随机推荐
Vscode configuration user code snippet
SLAAC stateless address automatic configuration
Upgrade POI TL version 1.12.0 and resolve the dependency conflict between the previous version of POI (4.1.2) and easyexcel
The impact of Patrick mchardy incident on the open source community
"Wei Lai Cup" 2022 Niuke summer multi school training camp 1 (summary of some topics)
Mongo from start to installation and problems encountered
Design and implementation of data analysis platform for intelligent commerce
别人发的word中的参考文献是{}这样的乱码格式怎么办
Leetcode 20 valid parentheses, 33 search rotation sort array, 88 merge two ordered arrays (nums1 length is m+n), 160 intersecting linked list, 54 spiral matrix, 415 character addition (cannot be direc
Ros2 common command line tools organize ros2cli
What is the product and expressiveness of 113700 Xingrui? Come and have a look
Demining game (analysis)
buu web
adobe PR2022 没有开放式字幕怎么办?
Worthington lysozyme technical description and literature reference
Energy principle and variational method note 11: shape function (a dimension reduction idea)
[untitled]
MOS摄像化、数字化”包含指定(contro.熟练的
SqlServer 备份还原
Successfully solved: error: SRC refspec master doors not match any