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 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</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 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 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 。有两种修改方法:
-
编辑 keosd 配置文件 ~/eosio-wallet/config.ini ,修改属性:http-server-address = 127.0.0.1:8899
-
使用命令行参数启动 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;">
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 !