EOS 測試網(wǎng)絡(luò)、賬號(hào)和錢包使用

上篇在ubuntu上編譯好eos,見http://www.itdecent.cn/p/f28bfb5830c3

一,開始搭建測試網(wǎng)絡(luò):
首先運(yùn)行eosd命令

cd ~/eos/build/programs/eosd/
./eosd

eosd命令執(zhí)行后會(huì)在當(dāng)前目錄生成data-dir目錄,
data-dir目錄會(huì)產(chǎn)生一個(gè)config.ini配置文件

cd ~/eos/build/programs/eosd/
vim data-dir/config.ini

修改為如下內(nèi)容,其中/home/chen/eos/build/genesis.json是編譯后自動(dòng)生成的:

# Track only transactions whose scopes involve the listed accounts. Default is to track all transactions.
# filter_on_accounts = 

# Limits the maximum time (in milliseconds) processing a single get_transactions call.
get-transactions-time-limit = 3

# File to read Genesis State from
# genesis-json = 

# override the initial timestamp in the Genesis State file
# genesis-timestamp = 

# the location of the block log (absolute path or relative to application data dir)
block-log-dir = "blocks"

# Sets the block interval in seconds.
block-interval-seconds = 1

# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.
# checkpoint = 

# Limits the maximum time (in milliseconds) that is allowed a transaction's code to execute from a received block.
rcvd-block-trans-execution-time = 72

# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute.
trans-execution-time = 18

# Limits the maximum time (in milliseconds) that is allowed a transaction's code to execute while creating a block.
create-block-trans-execution-time = 18

# The time frame, in seconds, that the per-authorized-account-transaction-msg-rate-limit is imposed over.
per-authorized-account-transaction-msg-rate-limit-time-frame-sec = 18

# Limits the maximum rate of transaction messages that an account is allowed each per-authorized-account-transaction-msg-rate-limit-time-frame-sec.
per-authorized-account-transaction-msg-rate-limit = 1800

# The time frame, in seconds, that the per-code-account-transaction-msg-rate-limit is imposed over.
per-code-account-transaction-msg-rate-limit-time-frame-sec = 18

# Limits the maximum rate of transaction messages that an account's code is allowed each per-code-account-transaction-msg-rate-limit-time-frame-sec.
per-code-account-transaction-msg-rate-limit = 18000

# Limits the maximum database storage that an account's code is allowed.
per-code-account-max-storage-db-limit-mbytes = 5

# The overhead to apply per row for approximating total database storage.
row-overhead-db-limit-bytes = 32

# The maximum depth the pending transaction queue will be allowed to reach till new pushed transactions are rejected.
pending-txn-depth-limit = 1000

# The maximum allowed for generating a block before subsequent transactions get put back on the pending transaction queue.
gen-block-time-limit-msec = 200

# open the database in read only mode
readonly = 0

# the location of the chain shared memory files (absolute path or relative to application data dir)
shared-file-dir = "blockchain"

# Minimum size MB of database shared memory file
shared-file-size = 8192

# Time to wait, in milliseconds, between creating next faucet created account.
faucet-create-interval-ms = 1000

# Name to use as creator for faucet created accounts.
faucet-name = faucet

# [public key, WIF private key] for signing for faucet creator account
faucet-private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]

# The local IP and port to listen for incoming http connections.
http-server-address = 127.0.0.1:8888

# Specify the Access-Control-Allow-Origin to be returned on each request.
# access-control-allow-origin = 

# Specify the Access-Control-Allow-Headers to be returned on each request.
# access-control-allow-headers = 

# Specify if Access-Control-Allow-Credentials: true should be returned on each request.
access-control-allow-credentials = false

# The actual host:port used to listen for incoming p2p connections.
p2p-listen-endpoint = 0.0.0.0:9876

# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint.
# p2p-server-address = 

# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network.
# p2p-peer-address = 

# The name supplied to identify this node amongst the peers.
agent-name = "EOS Test Agent"

# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined.
allowed-connection = any

# Optional public key of peer allowed to connect.  May be used multiple times.
# peer-key = 

# Tuple of [PublicKey, WIF private key] (may specify multiple times)
# peer-private-key = 

# Log level: one of 'all', 'debug', 'info', 'warn', 'error', or 'off'
log-level-net-plugin = info

# Maximum number of clients from which connections are accepted, use 0 for no limit
max-clients = 25

# number of seconds to wait before cleaning up dead connections
connection-cleanup-period = 30

# True to require exact match of peer network version.
network-version-match = 0

# number of blocks to retrieve in a chunk from any individual peer during synchronization
sync-fetch-span = 100

# Enable block production, even if the chain is stale.
#enable-stale-production = false

# Percent of producers (0-99) that must be participating in order to produce blocks
required-participation = false

# ID of producer controlled by this node (e.g. inita; may specify multiple times)
# producer-name = 

# Tuple of [public key, WIF private key] (may specify multiple times)
private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]

# Plugin(s) to enable, may be specified multiple times
# plugin = 
genesis-json = /home/chen/eos/build/genesis.json
 # Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin


修改完成后,運(yùn)行eosd,就啟動(dòng)了一個(gè)測試網(wǎng)絡(luò)

./eosd

二,使用錢包和賬戶
1,創(chuàng)建錢包
eosc wallet create會(huì)創(chuàng)建default錢包,在這里我們想創(chuàng)建自己命名的錢包

cd  ~/eos/build/programs/eosc/
./eosc wallet create -n wallet1

返回如下內(nèi)容,下面的password要保存好,用于解鎖被鎖定的錢包:

Creating wallet: wallet1
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JRLFvGrDVkhBiRadjaH7qHTyUYsiVp9Ep6UbtPw7LMFRTY11Aj"

2,查看錢包列表:

./eosc wallet list

返回如下內(nèi)容,帶星號(hào)的錢包表示處于解鎖可用狀態(tài):

Wallets:
[
  "wallet1 *"
]

3,鎖定和解鎖錢包:

#鎖定
./eosc wallet lock -n wallet1
#解鎖,輸入上面產(chǎn)生的密碼:PW5JRLFvGrDVkhBiRadjaH7qHTyUYsiVp9Ep6UbtPw7LMFRTY11Aj
./eosc wallet unlock -n wallet1

4,創(chuàng)建公鑰和私鑰對(duì),連續(xù)創(chuàng)建兩個(gè)用于owner和active權(quán)限

./eosc create key

返回:

Private key: 5K5MhSgUbBCwDUdX3xRnZsBxapbq8CJ2uKvwS5kiMBchdmjY6Ea
Public key: EOS7s1eAB9dbGnJzhhMbHnui1MA2PXbSycabio4JVDp9iJGAvRNSm
./eosc create key

返回:

Private key: 5KdT7YKf6p4aHqSqwtmGjvqdkQ2d4ZbX31F1mmLShbQ2eSUEe9n
Public key: EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG

5,把密鑰導(dǎo)入錢包

#如果使用default包,不需要使用-參數(shù)
./eosc wallet import -n wallet1 5K5MhSgUbBCwDUdX3xRnZsBxapbq8CJ2uKvwS5kiMBchdmjY6Ea
./eosc wallet import -n wallet1 5KdT7YKf6p4aHqSqwtmGjvqdkQ2d4ZbX31F1mmLShbQ2eSUEe9n

6、查詢錢包所包含的公鑰和私鑰

./eosc wallet keys

返回:

[[
    "EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG",
    "5KdT7YKf6p4aHqSqwtmGjvqdkQ2d4ZbX31F1mmLShbQ2eSUEe9n"
  ],[
    "EOS7s1eAB9dbGnJzhhMbHnui1MA2PXbSycabio4JVDp9iJGAvRNSm",
    "5K5MhSgUbBCwDUdX3xRnZsBxapbq8CJ2uKvwS5kiMBchdmjY6Ea"
  ]
]

7,創(chuàng)建賬戶,你需要一個(gè)生產(chǎn)者來創(chuàng)建賬戶,在config.ini里面我們定義了一個(gè)inita的生產(chǎn)者
他的公鑰和私鑰,寫死在這個(gè)配置文件里

private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]

運(yùn)行創(chuàng)建賬戶account1,一個(gè)公鑰用于owner,一個(gè)用于active,命令:

./eosc create account inita account1 EOS7s1eAB9dbGnJzhhMbHnui1MA2PXbSycabio4JVDp9iJGAvRNSm EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG 

會(huì)拋出錯(cuò)誤

1644950ms            main.cpp:1195                 main                 ] Failed with error: Assert Exception (10)
status_code == 200: Error code 401
: {"code":401,"message":"UnAuthorized","details":"signatures do not satisfy declared authorizations (3030002)\nTransaction declares authority '{\"account\":\"inita\",\"permission\":\"active\"}', but does not have signatures for it.\n"}

原因是inita賬戶沒有導(dǎo)入到wallet1錢包中,導(dǎo)入

./eosc wallet import -n wallet1 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

再重新運(yùn)行:

./eosc create account inita account1 EOS7s1eAB9dbGnJzhhMbHnui1MA2PXbSycabio4JVDp9iJGAvRNSm EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG 

返回如下信息成功:

OS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG 
{
  "transaction_id": "a529ba3116b0582de4889982dcb46f2cbed600b66d04fa20d7ce3d267ced0ec8",
  "processed": {
    "ref_block_num": 12722,
    "ref_block_prefix": 3892340324,
    "expiration": "2017-09-29T13:32:20",
    "scope": [
      "eos",
      "inita"
    ],
    "signatures": [
      "2047ef2f72aa20018b5a964573e21100f603198a477f600a4f81a437b3e448f997129f96f8c04a4bf8991a3b4a0e63d5a90ce4d1898c5ec9141dcce2b5a9dd5716"
    ],
    "messages": [{
        "code": "eos",
        "type": "newaccount",
        "authorization": [{
            "account": "inita",
            "permission": "active"
          }
        ],
        "data": {
          "creator": "inita",
          "name": "account1",
          "owner": {
            "threshold": 1,
            "keys": [{
                "key": "EOS7s1eAB9dbGnJzhhMbHnui1MA2PXbSycabio4JVDp9iJGAvRNSm",
                "weight": 1
              }
            ],
            "accounts": []
          },
          "active": {
            "threshold": 1,
            "keys": [{
                "key": "EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG",
                "weight": 1
              }
            ],
            "accounts": []
          },
          "recovery": {
            "threshold": 1,
            "keys": [],
            "accounts": [{
                "permission": {
                  "account": "inita",
                  "permission": "active"
                },
                "weight": 1
              }
            ]
          },
          "deposit": "0.0001 EOS"
        },
        "hex_data": "000000000093dd74000000214f4d113201000000010387bb96c7aafc02e568bee92b237b870f5f2f574ccdee88bad1e2f9dc5cfd2f80010000010000000102187158f7d82bca47825e960912be05c55635f662859d1ecb04eb01bbeb002d5a010000010000000001000000000093dd7400000000a8ed32320100010000000000000004454f5300000000"
      }
    ],
    "output": [{
        "notify": [],
        "deferred_trxs": []
      }
    ]
  }
}

8,備份密鑰
在 data-dir下面會(huì)有一個(gè)錢包文件wallet1.wallet生成,保存好這個(gè)文件。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. 賬戶與錢包1.1 創(chuàng)造并管理錢包1.2 生成EOS Keys并導(dǎo)入1.3 備份您的錢包1.4 創(chuàng)建賬戶 2....
    cenkai88閱讀 4,145評(píng)論 1 7
  • 一、快速術(shù)語檢索 比特幣地址:(例如:1DSrfJdB2AnWaFNgSbv3MZC2m74996JafV)由一串...
    不如假如閱讀 16,561評(píng)論 4 87

友情鏈接更多精彩內(nèi)容