Quick start EN - usechain/doc GitHub Wiki

中文版本


Warning

Since the Usechain mannet is alpha version, the tokens you get from Usechain faucet or from miner or from other ways is just for test. It has no real value now!

由于目前Usechain主网是alpha版本,从Usechain水龙头获取的币或者挖矿或者其他途径获取的币,都仅限于测试,目前没有实际价值!


This is an Usechain quick start manual for the user to build, create account, send transactions, do KYC ,register miner and mine.

The manual is base on OSX. If you use other operation system, it may be some difference.

Abstract

We welcome developers and users who are interested in Usechain to build the technology community together. We will reward outstanding developers, or offer work opportunities to build a truly decentralized world together.

  • Source Code go-usechain
  • Forum discord
  • Please submit bugs and your requirement directly on github's issues.

Pre-Condition

Hardware

  • CPU 1GHz single core or above- Free Memory 4 GB or above, 8GB is recommended- Broadband 1M Bps or above - Hard Disk 10GB free hard disk or above

Supported Operating Systems

We welcome you to provide reports on compatibility issues and operation testing document.

  • Mac OSX 10 or above
  • Redhat/Centos 6 or above
  • Ubuntu 14.4 or above
  • Windows 7 or above
  • Other Linux distributions

Software The build environment may rely on the following languages

  • go 1.9 or above
  • node.js 8.11 or above
  • npm 5 or above
  • python 3.5 or above
  • bash
  • git

Build from source

zhouhh@/Users/zhouhh/go/src/github.com/usechain/ $ git clone https://github.com/usechain/go-usechain.git

or pull from develop branch

zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ git pull

if you have tested Usechain before, you should backup and remove /Users/zhouhh/Library/usechain.

run make all to build and prepare environment.

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!

zhouhh@/Users/zhouhh/Library/usechain $ ls
mainnetCA.pem moonetCA.pem

Command help

if you need help, you can run 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

Init

After backup and clear /Users/zhouhh/Library/usechain,you shuld run init to initialize the contract and other configuration data for Usechain to run.

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

It will create tow directories,which is keystore and used.

Enter the console

run used console, to synchronize the mainnet block.--syncmode=full means to synchronize all blocks from the chain. without this parameter it means quick synchronization.

Other parameters you can type --help to get.

zhouhh@/Users/zhouhh/go/src/github.com/usechain/go-usechain git:(develop) $ ./build/bin/used console --syncmode=full

Trouble shooting

If you encountered with the error below:

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"

It means you need to remove the old block chain data,and init again. Please reference to [Init] chapter.

Account management

make new account.

> personal.newAccount()
Passphrase:
Repeat passphrase:
"UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm"
> personal.newAccount()
Passphrase:
Repeat passphrase:
"UmfaVTmQxX9SK47FmAG9toRJVeZMrzxR5tk"
> use.coinbase
"UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm"
> use.accounts
["UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm", "UmfaVTmQxX9SK47FmAG9toRJVeZMrzxR5tk"]

Get USE Token

To get some USE from https://mainnet.usechain.cn/#/gettoken/

please reference toGet test USE for free

get use

Send transactions:

> 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:

For details ,please reference to 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"}}

After being verified by the CA adminstrator, you can get the certificate.

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

please reference to genesis.json for Credit Register Contract address.

> 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

retuns 1 means it was passed by the committee.

Be a miner

Details please review from miner

> personal.unlockAccount(use.accounts[0])
Unlock account UmUYMXuZPZGs89vwPZGUhrSv3rxVe2SoxVm
Passphrase:
true
> use.minerRegister({from:use.accounts[0]})
Error: insufficient funds for gas * price + value

You should have more than 50 USE to be locked. This value will be adjusted by sitiation. If you don't have enough USE, it will give an error of insufficient funds.

> 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()

If you didn't run miner.stop(), and you can't mining, eg. the network is disconnected, or the program exited, you should be punished. More than 3 times you will be added to blacklist, and can't be a miner forever.

> 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

⚠️ **GitHub.com Fallback** ⚠️