EOS 测试网络、账号和钱包使用

上篇在ubuntu上编译好eos,见https://www.jianshu.com/p/f28bfb5830c3

一,开始搭建测试网络:
首先运行eosd命令

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

eosd命令执行后会在当前目录生成data-dir目录,
data-dir目录会产生一个config.ini配置文件

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

修改为如下内容,其中/home/chen/eos/build/genesis.json是编译后自动生成的:

# 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


修改完成后,运行eosd,就启动了一个测试网络

./eosd

二,使用钱包和账户
1,创建钱包
eosc wallet create会创建default钱包,在这里我们想创建自己命名的钱包

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

返回如下内容,下面的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

返回如下内容,带星号的钱包表示处于解锁可用状态:

Wallets:
[
  "wallet1 *"
]

3,锁定和解锁钱包:

#锁定
./eosc wallet lock -n wallet1
#解锁,输入上面产生的密码:PW5JRLFvGrDVkhBiRadjaH7qHTyUYsiVp9Ep6UbtPw7LMFRTY11Aj
./eosc wallet unlock -n wallet1

4,创建公钥和私钥对,连续创建两个用于owner和active权限

./eosc create key

返回:

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

返回:

Private key: 5KdT7YKf6p4aHqSqwtmGjvqdkQ2d4ZbX31F1mmLShbQ2eSUEe9n
Public key: EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG

5,把密钥导入钱包

#如果使用default包,不需要使用-参数
./eosc wallet import -n wallet1 5K5MhSgUbBCwDUdX3xRnZsBxapbq8CJ2uKvwS5kiMBchdmjY6Ea
./eosc wallet import -n wallet1 5KdT7YKf6p4aHqSqwtmGjvqdkQ2d4ZbX31F1mmLShbQ2eSUEe9n

6、查询钱包所包含的公钥和私钥

./eosc wallet keys

返回:

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

7,创建账户,你需要一个生产者来创建账户,在config.ini里面我们定义了一个inita的生产者
他的公钥和私钥,写死在这个配置文件里

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

运行创建账户account1,一个公钥用于owner,一个用于active,命令:

./eosc create account inita account1 EOS7s1eAB9dbGnJzhhMbHnui1MA2PXbSycabio4JVDp9iJGAvRNSm EOS55FiCrEu5rdtPUuUhVbDCvUcvYF64PYHh9Lj39TrH58WHj2yLG 

会抛出错误

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账户没有导入到wallet1钱包中,导入

./eosc wallet import -n wallet1 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

再重新运行:

./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下面会有一个钱包文件wallet1.wallet生成,保存好这个文件。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,837评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,551评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,417评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,448评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,524评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,554评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,569评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,316评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,766评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,077评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,240评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,912评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,560评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,176评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,425评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,114评论 2 366
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,114评论 2 352

推荐阅读更多精彩内容

  • 1. 账户与钱包1.1 创造并管理钱包1.2 生成EOS Keys并导入1.3 备份您的钱包1.4 创建账户 2....
    cenkai88阅读 3,943评论 1 7
  • 一、快速术语检索 比特币地址:(例如:1DSrfJdB2AnWaFNgSbv3MZC2m74996JafV)由一串...
    不如假如阅读 15,919评论 4 87