Solidity Weekly #14

mingderwang
Oct 4, 2018 · 6 min read

如何使用 ZeppelinOS 產生 ERC20 tokens

本期不寫 Code

讓我們在 Ropsten Test net 上測試,用 ZeppelinOS 直接產生 ERC20 tokens。

先安裝與架設好 zos for Rosten network deployment:

cd /tmp && mkdir my-app && cd my-app
npm install -g yarn zos
zos init my-app 1.0.0
zos link openzeppelin-zos
// (10/28/2018) 改成
zos link openzeppelin-eth
// truffle-config.js 修改 ropsten 連線與預設帳號, 如下rm truffle-config.js && wget https://gist.githubusercontent.com/mingderwang/17ef06e6960268accfbe9592beee8dc2/raw/1be8a6f0100a3e31138b7dca6588ece1e4471134/truffle-config.jsyarn add openzeppelin-zos truffle-hdwallet-provider
zos push --network ropsten
// (10/28/2018) 改成
yarn add openzeppelin-eth truffle-hdwallet-provider
zos push --network ropsten
Image for post
npm openzeppelin-zos 改名為 openzeppelin-eth

然後執行以下指令,假設你在 Ropsten 有一個帳號 ,例如這裡的 0x66ee73086134f147745be72335153bf780499e2e,當成這 tokens 合約的所有人,您可更改 muzha 成你要的 token 名稱,以及改 MUZA 成你要的 token 符號。

只要一行指令, 就可以生成 tokens:

在 /tmp/my-app 目錄下

OWNER=0x66ee73086134f147745be72335153bf780499e2e zos create DetailedPremintedToken --init initialize --args $OWNER,muzha,MUZA,8,100000000000000000000 --network ropsten

結果如下,就可以產生一兆個 ERC20 tokens,合約位址在 0xc634d06c9d0fac3c6b341dc6238a15f253caecf9

Creating DetailedPremintedToken proxy and calling initialize with:
- _sender (address): "0x66ee73086134f147745be72335153bf780499e2e"
- _name (string): "muzha"
- _symbol (string): "MUZA"
- _decimals (uint8): "8"
- _initialBalance (uint256): "100000000000000000000"
TX receipt received: 0x6aa11e9a8465092ee17642703aeec1272e1dda452a028da1f460bbcd75dac6d8
DetailedPremintedToken proxy: 0xc634d06c9d0fac3c6b341dc6238a15f253caecf9
Successfully written zos.ropsten.json

可以利用 Ropsten 的 Etherscan 做驗證如下:

LT;DR

安裝 zos 與 truffle 這麼麻煩,乾脆用 docker,結果是一樣的:

docker run mingder78/create-erc20-token 0x66ee73086134f147745be72335153bf780499e2e,TaiwanNewToken,TNT,8,100000000000000000000

$ docker run mingder78/create-erc20-token 0x66ee73086134f147745be72335153bf780499e2e,TaiwanNewToken,TNT,8,100000000000000000000
Creating DetailedPremintedToken proxy and calling initialize with:
— _sender (address): “0x66ee73086134f147745be72335153bf780499e2e”
— _name (string): “TaiwanNewToken”
— _symbol (string): “TNT”
— _decimals (uint8): “8”
— _initialBalance (uint256): “100000000000000000000”
TX receipt received: 0xfa424db886ea3bcdfa79bed262c41b82b2a028dfdc240bfb47e067ae34ae4aa6
DetailedPremintedToken proxy: 0x5e19e1830d452e64157c3a49978607f02d79bbf8
Successfully written zos.ropsten.json
0x5e19e1830d452e64157c3a49978607f02d79bbf8

Taipei Ethereum Meetup

台北以太坊社群專欄

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store