-
Notifications
You must be signed in to change notification settings - Fork 3
Quick start
由于目前Usechain主网是alpha版本,从Usechain水龙头获取的币或者挖矿或者其他途径获取的币,都仅限于测试,目前没有实际价值!
本文档是Usechain快速使用手册,用于帮组用户创建帐户,发送交易事务,制作KYC,注册矿工和挖矿等操作。
本手册基于OSX操作系统. 如果使用其他的操作系统,部分地方可能有一些不一样。
我们欢迎对usechain感兴趣的开发人员和用户一起构建技术社区, 我们将奖励优秀的开发人员,或者提供工作机会,共同构建一个真正的去中心化的世界。
- 源码 go-usechain
- 讨论 discord
- 请在github的issue提交bug和你的需求。
- CPU 1GHz单核或以上;内存4GB或以上,建议8GB;宽带1M Bps或以上;硬盘10GB或以上。
欢迎大家提供有关兼容性问题的报告和操作测试等文件。
- Mac OSX 10 或以上
- Redhat/Centos 6 或以上
- Ubuntu 14.4 或以上
- Windows 7 或以上
- 其他的Linux版本
- go 1.9 或以上
- node.js 8.11 或以上
- npm 5 或以上
- python 3.5 或以上
- bash
- git
zhouhh@/Users/zhouhh/go/src/github.com/usechain/ $ git clone https://github.com/usechain/go-usechain.git切换到develop分支,执行pull命令更新源码
zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ git pull
如果以前有测试,需要备份并清空/Users/zhouhh/Library/usechain,其中zhouhh替换为您自己的用户名。该目录是缺省存放证书和数据的目录。
执行 make all创建运行准备环境。
zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ make all
build/env.sh go run build/ci.go install
The minimum golang version required is: 1.10.1
Your current golang version is : 1.12.
Your golang version is OK!
...
Usechain ConfigDir: /Users/zhouhh/Library/usechain
prepare configure files....
ls /Users/zhouhh/Library/usechain:
history keystore mainnetCA.pem moonetCA.pem used
Done!
此时会将主网和测试网证书放到/Users/zhouhh/Library/usechain目录下,并在build/bin下生成used等二进制文件。
zhouhh@/Users/zhouhh/Library/usechain $ ls
mainnetCA.pem moonetCA.pem
如果你需要帮助,你可以运行used --help。
zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ ./build/bin/used --help
NAME:
used - the go-usechain command line interface
Copyright 2017-2018 The go-usechain Authors
USAGE:
used [options] command [command options] [arguments...]
VERSION:
0.0.1-use-c1c87989
COMMANDS:
account Manage accounts
attach Start an interactive JavaScript environment (connect to node)
bug opens a window to report a bug on the geth repo
console Start an interactive JavaScript environment
copydb Create a local chain from a target chaindata folder
dump Dump a specific block from storage
dumpconfig Show configuration values
export Export blockchain into file
import Import a blockchain file
init Bootstrap and initialize a new genesis block
js Execute the specified JavaScript files
monitor Monitor and visualize node metrics
removedb Remove blockchain and state databases
verify Verify address
wallet Manage Usechain presale wallets
help, h Shows a list of commands or help for one command
USECHAIN OPTIONS:
--config value TOML configuration file
--datadir "/Users/zhouhh/Library/usechain" Data directory for the databases and keystore
--keystore Directory for the keystore (default = inside the datadir)
--nousb Disables monitoring for and managing USB hardware wallets
--networkid value Network identifier (integer, 1=Frontier, 2=Moonet) (default: 1)
--testnet test network: pre-configured random-proof-of-work test network
--moonet moonet network: pre-configured random-proof-of-work test network
--syncmode "fast" Blockchain sync mode ("fast", "full", or "light")
--gcmode value Blockchain garbage collection mode ("full", "archive") (default: "full")
--ethstats value Reporting URL of a ethstats service (nodename:secret@host:port)
--identity value Custom node name
--id value User identity id
--info value User identity info file
--moonetca User register CA server
--photo value User identity photos
--query value query for CA
--lightserv value Maximum percentage of time allowed for serving LES requests (0-90) (default: 0)
--lightpeers value Maximum number of LES client peers (default: 100)
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
DEVELOPER CHAIN OPTIONS:
--dev Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
--dev.period value Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)
RPOW OPTIONS:
TRANSACTION POOL OPTIONS:
--txpool.nolocals Disables price exemptions for locally submitted transactions
--txpool.journal value Disk journal for local transaction to survive node restarts (default: "transactions.rlp")
--txpool.rejournal value Time interval to regenerate the local transaction journal (default: 1h0m0s)
--txpool.pricelimit value Minimum gas price limit to enforce for acceptance into the pool (default: 1000000)
--txpool.pricebump value Price bump percentage to replace an already existing transaction (default: 10)
--txpool.accountslots value Minimum number of executable transaction slots guaranteed per account (default: 16)
--txpool.globalslots value Maximum number of executable transaction slots for all accounts (default: 8192)
--txpool.accountqueue value Maximum number of non-executable transaction slots permitted per account (default: 2048)
--txpool.globalqueue value Maximum number of non-executable transaction slots for all accounts (default: 16384)
--txpool.lifetime value Maximum amount of time non-executable transaction are queued (default: 3h0m0s)
PERFORMANCE TUNING OPTIONS:
--cache value Megabytes of memory allocated to internal caching (default: 1024)
--cache.database value Percentage of cache memory allowance to use for database io (default: 75)
--cache.gc value Percentage of cache memory allowance to use for trie pruning (default: 25)
--trie-cache-gens value Number of trie node generations to keep in memory (default: 120)
ACCOUNT OPTIONS:
--unlock value Comma separated list of accounts to unlock
--password value Password file to use for non-interactive password input
API AND CONSOLE OPTIONS:
--rpc Enable the HTTP-RPC server
--rpcaddr value HTTP-RPC server listening interface (default: "localhost")
--rpcport value HTTP-RPC server listening port (default: 8848)
--rpcapi value API's offered over the HTTP-RPC interface
--ws Enable the WS-RPC server
--wsaddr value WS-RPC server listening interface (default: "localhost")
--wsport value WS-RPC server listening port (default: 8849)
--wsapi value API's offered over the WS-RPC interface
--wsorigins value Origins from which to accept websockets requests
--ipcdisable Disable the IPC-RPC server
--ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)
--rpccorsdomain value Comma separated list of domains from which to accept cross origin requests (browser enforced)
--rpcvhosts value Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
--jspath loadScript JavaScript root path for loadScript (default: ".")
--exec value Execute JavaScript statement
--preload value Comma separated list of JavaScript files to preload into the console
NETWORKING OPTIONS:
--bootnodes value Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)
--bootnodesv4 value Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)
--bootnodesv5 value Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
--port value Network listening port (default: 40404)
--maxpeers value Maximum number of network peers (network disabled if set to 0) (default: 25)
--maxpendpeers value Maximum number of pending connection attempts (defaults used if set to 0) (default: 0)
--nat value NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
--nodiscover Disables the peer discovery mechanism (manual peer addition)
--v5disc Enables the experimental RLPx V5 (Topic Discovery) mechanism
--netrestrict value Restricts network communication to the given IP networks (CIDR masks)
--nodekey value P2P node key file
--nodekeyhex value P2P node key as hex (for testing)
MINER OPTIONS:
--committee Enable committing
--mine Enable mining
--minerthreads value Number of CPU threads to use for mining (default: 4)
--usebase value Public address for block mining rewards (default = first account created) (default: "0")
--targetgaslimit value Target gas limit sets the artificial target gas floor for the blocks to mine (default: 21000000)
--gasprice "1000000000" Minimal gas price to accept for mining a transactions
--extradata value Block extra data set by the miner (default = client version)
GAS PRICE ORACLE OPTIONS:
--gpoblocks value Number of recent blocks to check for gas prices (default: 20)
--gpopercentile value Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 60)
VIRTUAL MACHINE OPTIONS:
--vmdebug Record information useful for VM and contract debugging
LOGGING AND DEBUGGING OPTIONS:
--metrics Enable metrics collection and reporting
--fakepow Disables random-proof-of-work verification
--nocompaction Disables db compaction after import
--verbosity value Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 3)
--vmodule value Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
--backtrace value Request a stack trace at a specific logging statement (e.g. "block.go:271")
--debug Prepends log messages with call-site location (file and line number)
--pprof Enable the pprof HTTP server
--pprofaddr value pprof HTTP server listening interface (default: "127.0.0.1")
--pprofport value pprof HTTP server listening port (default: 6060)
--memprofilerate value Turn on memory profiling with the given rate (default: 524288)
--blockprofilerate value Turn on block profiling with the given rate (default: 0)
--cpuprofile value Write CPU profile to the given file
--trace value Write execution trace to the given file
WHISPER (EXPERIMENTAL) OPTIONS:
--shh Enable Whisper
--shh.maxmessagesize value Max message size accepted (default: 1048576)
--shh.pow value Minimum POW accepted (default: 0.2)
DEPRECATED OPTIONS:
--fast Enable fast syncing through state downloads
--light Enable light client mode
MISC OPTIONS:
--help, -h show help
COPYRIGHT:
Copyright 2017-2018 The go-usechain Authors
初始化主要完成内置合约和网络,配置初始化。
zhouhh@/Users/zhouhh/git/go-usechain git:(develop) ✗ $ ./build/bin/used init build/config/genesis.json
zhouhh@/Users/zhouhh/Library/usechain $ ls -l
total 16
drwx------ 2 zhouhh staff 64 Jun 17 15:59 keystore
-rw-r--r-- 1 zhouhh staff 1155 Jun 17 15:55 mainnetCA.pem
-rw-r--r-- 1 zhouhh staff 1172 Jun 17 15:55 moonetCA.pem
drwxr-xr-x 4 zhouhh staff 128 Jun 17 15:59 used
此时会创建keystore和used两个目录。
执行 used console命令, 开始同步主网区块。--syncmode=full表示同步主网的完整区块,没有该参数表示执行快速同步。
其他参数你可以通过执行 --help 来获取以及参考。
zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ ./build/bin/used console --syncmode=full
控制台会不停的打印同步信息等日志,这是正常现象,不会影响你的命令行输入操作。执行 use.blockNumber命令查看到同步的高度。同步需要一段时间,请耐心等待。
如果遇到类似下面的错误:
ERROR[06-17|15:51:03] Failed to decode state object addr=0x0000000000000000000000000000000000000000 err="rlp: expected input list for common.Lock, decoding into (state.Account).Lock"
表示你应该备份并清空原有区块数据。请参考[初始化]章节。
> personal.newAccount()
Passphrase:
Repeat passphrase:
"UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm"
> personal.newAccount()
Passphrase:
Repeat passphrase:
"UmfaVTmQxX9SK47FmAG9toRJVeZMrzxR5tk"
> use.coinbase
"UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm"
> use.accounts
["UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm", "UmfaVTmQxX9SK47FmAG9toRJVeZMrzxR5tk"]
获取USE: https://mainnet.usechain.cn/#/gettoken/
请参考免费获取测试USE

> use.getBalance(use.accounts[0])
100000000000000000000
> use.getBalance(use.accounts[1])
0
> personal.unlockAccount(use.accounts[0])
Unlock account UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm
Passphrase:
true
> use.sendTransaction({from:use.accounts[0],to:use.accounts[1],value:web3.toHui("80", "USE")})
INFO [06-17|16:57:25] Submitted transaction fullhash=0xffe1fcb1a94c5b61637db38f1cbf4aff0c1c101af36d75ec72e21546abfa1c35 recipient=UmfaVTmQxX9SK47FmAG9toRJVeZMrzxR5tk
"0xffe1fcb1a94c5b61637db38f1cbf4aff0c1c101af36d75ec72e21546abfa1c35"
> use.getBalance(use.coinbase)
19999958000000000000
> use.getBalance(use.accounts[1])
80000000000000000000
详情请参考Do kyc
zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ ./build/bin/used verify
+--------------------------------------------------------------------------+
| Welcome to usechain, the first mirror identity blockchain |
| |
| This command lets you create a new identity to registered |
| e.g ./build/bin/used verify // create your new json info file |
| e.g ./build/bin/used --info=<json info file> --photo=<photo1;photo2> |
+--------------------------------------------------------------------------+
Which certificate do you use for registered?
1. IDCard
2. Others
> 1
What is your ID number?
> 432021198503380214
What is your name?
> 王小川
What is your gender?
0. Male
1. Female
2. Others
> 0
What is your country? Please refer to https://en.wikipedia.org/wiki/ISO_3166-1
> cn
What is your address? (optional)
>
Now the file name is set to userData.json!
INFO [03-29|15:18:50] Exported user info
zhouhh@/Users/zhouhh/git/usechain/src/github.com/usechain/go-usechain git:(develop) ✗ $ ./build/bin/used verify --info=userData.json --photo="/Users/zhouhh/Pictures/id1.png;/Users/zhouhh/Pictures/id2.png;/Users/zhouhh/Pictures/id3.png"
INFO [06-17|17:01:46] Read photo: Name=/Users/zhouhh/Pictures/id1.png
INFO [06-17|17:01:46] Read photo: Name=/Users/zhouhh/Pictures/id2.png
INFO [06-17|17:01:46] Read photo: Name=/Users/zhouhh/Pictures/id3.png
INFO [06-17|17:01:46] Private key saved at /Users/zhouhh/Library/usechain/userrsa.prv
INFO [06-17|17:01:46] Public key saved at /Users/zhouhh/Library/usechain/userrsa.pub
{"status":0,"msg":"success","data":{"idKey":"733557724611016ea6d4e97b50dcef8b"}}
经过CA管理员的认证后,你会获得证书。
zhouhh@/Users/zhouhh/git/usechain/src/github.com/usechain/go-usechain git:(develop) ✗ $ ./build/bin/used verify --query=733557724611016ea6d4e97b50dcef8b
INFO [06-17|17:03:50] query url for idKey: idKey=733557724611016ea6d4e97b50dcef8b
INFO [06-17|17:03:50] CAbuf: CAbuf="{\"status\":0,\"msg\":\"success\",\"data\":{\"cert\":\"-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----\\n\"}}"
INFO [06-17|17:03:50] Verification successful, your CA file stored in /Users/zhouhh/Library/usechain/user.crt
> personal.unlockAccount(use.accounts[0])
Unlock account UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm
true
请根据genesis.json文件,找到验证合约的地址,以确保正确性。
> use.sendCreditRegisterTransaction({from:use.accounts[0],to:"UmixYUgBHA9vJj47myQKn8uZAm4an7zyYJ8",gas:3000000, gasPrice:10000000000})
INFO [06-17|17:09:17] Submitted transaction fullhash=0x3eaf274226002f56b13ca39d4538e4f8fc96d8e4fc745cb093b304ef85919b18 recipient=UmixYUgBHA9vJj47myQKn8uZAm4an7zyYJ8
"0x3eaf274226002f56b13ca39d4538e4f8fc96d8e4fc745cb093b304ef85919b18"
> use.getCertifications(use.accounts[0])
1
返回1表示已被委员会验证通过。
详情请参考成为矿工
> personal.unlockAccount(use.accounts[0])
Unlock account UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm
Passphrase:
true
> use.minerRegister({from:use.accounts[0]})
Error: insufficient funds for gas * price + value
你应该保证余额大于50USE以上。其中50USE是质押锁定的,会随着网络情况而调整。否则会报余额不足错误。
> personal.unlockAccount(use.accounts[1])
Unlock account UmfaVTmQxX9SK47FmAG9toRJVeZMrzxR5tk
Passphrase:
true
> use.sendTransaction({from:use.accounts[1],to:use.accounts[0],value:web3.toHui("50", "USE")})
INFO [06-17|17:25:46] Submitted transaction fullhash=0x3a4260e2f7b4fe4f50ae39b8b47e34853c554c889478629a75d4d6962676205d recipient=UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm
"0x3a4260e2f7b4fe4f50ae39b8b47e34853c554c889478629a75d4d6962676205d"
> use.minerRegister({from:use.accounts[0]})
INFO [06-17|19:04:48] Submitted transaction fullhash=0x04764e180ca7de4fc28fa074144b48c9bcfc351a9549a99d83507d9cd052f5a4 recipient=UmixYUgBHA9vJj47myQKn8uZAm4anEfrG78
"0x04764e180ca7de4fc28fa074144b48c9bcfc351a9549a99d83507d9cd052f5a4"
> use.isMiner(use.accounts[0])
1
> personal.unlockAccount(use.coinbase,"passwd",500000)
true
> miner.start()
INFO [06-17|19:07:15] Commit new mining work number=69765 txs=0 elapsed=3.429ms
INFO [06-17|19:07:15] Successfully sealed new block number=69765 hash=d00e5f…cc710d
INFO [06-17|19:07:15] 🔨 mined potential block number=69765 hash=d00e5f…cc710d
INFO [06-17|19:07:15] blockNumber index=69765
INFO [06-17|19:07:15] block time slot time=5
INFO [06-17|19:08:15] 🔗 block reached canonical chain number=69765 hash=d00e5f…cc710d
> use.getBlock(69765)
{...
miner: "UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm",
...}
> use.coinbase
"UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm"
> miner.stop()
如果没有执行miner.stop(), 而又不能挖矿,如网络断了,或程序直接退出,则可能被惩罚。被惩罚3次后将被列入黑名单,不能加入挖矿。
> miner.start()
INFO [06-18|09:43:24] Transaction pool price threshold updated price=1000000000
INFO [06-18|09:43:24] Usebase automatically configured address=UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm
INFO [06-18|09:43:24] Miner on line Msg is sent hash=0x153b31cde07d24244374197a71e7e2d59bbc079b667779f5ff4c470938c7b92f
INFO [06-18|09:43:24] Starting mining operation
null
> WARN [06-18|09:43:24] Coinbase's misconducts: misconducts=150
WARN [06-18|09:43:24] Coinbase is being punished, Mining will commence after: blockNumber=87406
This is the Wiki for the official Usechain golang implementation.