2018-09-08

账户与钱包


重要提醒:该教程面向私有的单节点测试网络,但稍加修改也能在公共网络上使用。该教程目的是针对发者对钱包,密钥以及账户的一个底层的教学,以便更好地理解 EOSIO。


前言

教程受众

本教程针适用于开发者,可以帮助他们了解学习:

  • 钱包和账户管理

  • 如何使用 cleos 管理钱包和账户

  • 钱包和账户管理这些 EOSIO 组件是如何进行交互的

关于 cleos 的其余信息可以在Cleos 命令参考中获取。


你将学到什么

  • 创建和管理钱包以及密钥

  • 通过 cleos 命令行使用创建的钱包与区块链进行交互

  • 如何使用 cleos 创建账户

  • 通过 cleos,keosd ,nodeos 之间的交互,对发布到区块链上的内容进行签名。


EOSIO账户和钱包概念

下图展示了EOSIO中账户和钱包之间的一个简单概念图。

可以把钱包视为一个加密编码的公私钥对仓库。钱包以及其中的内容由 keosd 管理,通过 cleos 访问钱包。

可以把账户视为一个链上标识符,其具有与之相关的访问权限(例如一个安全主体)。nodeos 管理账户的发布以及链上账户相关的操作。nodeos 的账户管理能力也能通过 cleos 进行访问。

账户和钱包之间没有任何内在联系。账户对钱包一无所知,反之亦然。相应地,nodeos 和 keosd 之间也没有任何内在联系。它们的基础功能完全不同。(话虽如此,但也有一些部署配置模糊了这种区别。但这个超出了本教程的范围,所以这里不涉及。)

钱包和账户有交集的地方就是即需要签名的场景,如对交易进行签名。钱包有利于以一种安全的模式获取签名, 该模式将密钥锁定加密存储在本地。这是 cleos 就是充当 keosd 和 nodeos 之间的一个中间人,keosd 负责检索密钥,nodeos 负责需要使用这些密钥签名的账户相关(以及其他)操作。


创建并管理钱包

进入 EOSIO 安装目录,输入:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n58" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet create --to-console
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"这里是钱包对应的 master password! "</pre>

现在名为 default 的钱包已经创建成功,并返回一个 master password,需要妥善保管好该密码,往后解锁(解密)钱包文件需要用到。

这个钱包对应的文件为 default.wallet 。keosd 默认会将钱包文件存储在 ~/eosio-wallet 文件夹中。钱包数据文件夹的位置可以通过命令行参数 --wallet-dir 来指定。


管理多个钱包以及钱包命名

cleos 能够管理多个钱包。每个单独的钱包都有不同的密码来保护。以下例子我们创建另一个钱包并且演示如何使用参数 -n 参数进行命名。

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n67" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet create -n garyWallet --to-console
Creating wallet: garyWallet
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"A MASTER PASSWORD"</pre>

下面我们确认一下自命名的钱包是否已创建:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n70" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet list
Wallets:
[
"default",
"garyWallet *"
]</pre>

其中有(*****)标识的钱包标识其当前没有锁定,当使用 create wallet 命令时,为了操作方便,默认所创建的钱包属于解锁状态。

我们试试 wallet lock 命令:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n75" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet lock -n garyWallet
Locked: garyWallet</pre>

我们再次执行 wallet list 命令,就会看到所有钱包都以锁定:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n78" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet list
Wallets:
[
"default",
"garyWallet"
]</pre>

执行 wallet list 命令,附带 - n 参数指定钱包名称以及 - -password 参数对应钱包的密码:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n81" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet unlock -n periwinkle --password YOUR_MASTER_KEY</pre>

命令行窗口会输出提示钱包已解锁,同时你也可以调用命令检查一遍:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n84" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
Unlocked: 'periwinkle'
$ cleos wallet list
Wallets:
[
"default *",
"garyWallet *"
]</pre>

上文我们说过,cleos 会自动启动 kesod 进程。现在我们停止 keosd 进程:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n87" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
ps aux|grep kesod
kill keosd的进程pid
$ cleos wallet list
wallets:
[]</pre>

上面命令中,我们先 kill keosd进程,然后再执行钱包查询命令,而且这时候 keosd 也由于cleos 命令的调用自动启动了 ,但是却没有查出任何钱包,这是为什么呢?

在对钱包进行操作之前(包括 list 操作),需要先打开钱包(open)。当你杀掉 keosd 进程时,钱包会被加锁。当 keosd 进程重启时,钱包并不会自动打开。执行下面命令打开钱包:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n92" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
cleos wallet open /* 同样 -n 指定具体的钱包*/ cleos wallet list
Wallets:
[
"default"
]</pre>

现在,我们已经掌握了如果创建过个钱包,并通过 cleos 命令与之交互了。但是,一个空钱包并没有什么作用。接下来我们来学习如何将密钥导入到钱包中。


生成 EOSIO 密钥对并导入

生成 EOSIO 密钥对有多种方式,但本教程偏向于在 cleos 中使用 create Key 命令。

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n99" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
cleos create key --to-console Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Public key: EOSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX cleos create key --to-console
Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Public key: EOSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</pre>

使用 --file filename 参数替代 --to-console,可以将你的密钥对写入本地文件。

现在我们生成了两个 EOSIO 键值对。但目前它们只是一些随机的键值对且没有任何权利。

接下来,我们将导入私钥(private key)到 default 钱包中。我们会执行 wallet import 两次,使用前面生成的两个私钥。(如果钱包锁定了,得先解锁)

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n106" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
cleos wallet unlock password: Unlocked: default cleos wallet import --private-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
imported private key for: EOS6FzRdKEfSozzvjRsAWhvbSoCZ8JWD4sHm16gT21tQ3viK4sajQ
$ cleos wallet import --private-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
imported private key for: EOS65UPCFro71rAUudMZEC5VZRnk65KEb364jBUEpEt7tZbnrwJLT</pre>

我们可以检查哪些密钥已经被装载到钱包中了,使用 wallet keys 只能显示公钥,使用 wallet private_keys 公钥私钥都显示,这两个命令只会列出已解锁的钱包。

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n109" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
cleos wallet keys [ "EOS6....", "EOS3...." ] cleos wallet private_keys --password YOUR WALLET PASSWORD
password:
[[
"EOS6....",
"5KQwr..."
],
[
"EOS3....",
"5Ks0e..."
]
]</pre>

钱包文件本身是加密的,所以当钱包已锁定时能起到保护密钥的作用。访问一个已锁定的钱包中的密钥需要钱包的密码。


钱包备份

现在你的钱包已经有了密钥对,就需要养成钱包备份的好习惯,例如备份到 USB 以及其他存储媒介等,防止钱包文件丢失。钱包文件是经过了高度加密的,如果没有钱包密码,钱包内的密钥信息几乎是无法访问的。

钱包数据默认存储在 ~/eosio-wallet 文件夹中。(或者在你之前创建钱包指定的 --data-dir 参数路径中 )

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n118" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cd ~/eosio-wallet && ls
config.ini default.wallet garyWallet.wallet wallet.lock</pre>


创建一个账户

要执行链上操作需要有一个账户。我们使用 cleos 向 nodeos 请求创建账户并发布到区块链上。在本教程中,我们需要启动 nodeos 进程。下面的命令将会启动一个单节点测试网络。关于安装本地环境的详细内容请看创建并启动一个单节点测试网络

在本教程中,我们需要同时运行 keosd 和 nodeos 进程。目前这两个进程的默认端口都是 8888。本教程为了简化运行 nodeos 的步骤,我们将 keosd 的端口 改为8899 。有两种修改方法:

  1. 编辑 keosd 配置文件 ~/eosio-wallet/config.ini ,修改属性:http-server-address = 127.0.0.1:8899

  2. 使用命令行参数启动 keosd --http-server-address=localhost:8899

平兄使用第二种方式:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n134" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
pkill keosd nohup keosd --http-server-address=localhost:8899 > /dev/null 2>&1 &
$ cleos --wallet-url=http://localhost:8899 wallet unlock /* keosd 重启需要解锁 */</pre>

接下来启动 nodeos ,新建一个终端窗口,运行:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n137" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ nohup nodeos -e -p eosio --eosio::chain_api_plugin --plugin eosio::history_api_plugin > /dev/null 2>&1 &
[1] 21244</pre>

在本实例中,eosio 是授权账户,区块链上的操作必须使用与 eosio 账户关联的密钥进行签名。eosio 账户是一个特殊的账户,用于引导 EOSIO 节点。该账户的密钥可以在 nodeos 进程的配置文件中找到,linux 环境下位置为:~/.local/share/eosio/nodeos/config/config.ini

我们需要把账户 eosio 的私钥导入到 default 钱包中,以便下文创建新账户。

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n142" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3</pre>

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n143" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos create account authorizing_account NEW_ACCOUNT OWNER_KEY ACTIVE_KEY</pre>

  • authorizing_account :为新建的账户提供资金的账户。

  • new_account :新建账户名。

  • owner_key :所有权权限公钥。

  • active_key :管理权权限公钥。

现在我们创建一个新的账户:

<pre class="md-fences md-end-block" lang="shell" contenteditable="false" cid="n159" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Consolas, "Liberation Mono", Courier, monospace; font-size: 0.9em; white-space: pre; text-align: left; break-inside: avoid; display: block; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(223, 226, 229); border-radius: 3px; padding: 8px 1em 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
$ cleos --wallet-url=http://localhost:8899 create account eosio eospingxiong 所有权公钥 支配权公钥
executed transaction: a64bf59e0c0a75ba0a4a408af1e7f61da27958ef8952d81329bff3795fed288b 200 bytes 66641 us

eosio <= eosio::newaccount {"creator":"eosio","name":"eospingxiong","owner":{"threshold":1,"keys":[{"key":"EOS65UPCFro71rAUudMZ...

warning: transaction executed locally, but may not be confirmed by the network yet ] </pre>

如果看到以上的输出,恭喜你,you make it !

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

推荐阅读更多精彩内容