本篇主要总结环境搭建过程中遇到的问题,以及对基础概念的理解。至于具体搭建流程,官方文档已经很清楚了,不再赘述。
1、搭建内容
主要包括安装eosio、eosio.cdt、启动eos、创建钱包以及创建账号等。
eosio.cdt:The EOSIO Contract Development Toolkit, CDT for short, is a collection of tools related to contract compilation. Subsequent tutorials use the CDT primarily for compiling contracts and generating ABIs.
钱包:Wallets are repositories of public-private key pairs. Private keys are needed to sign operations performed on the blockchain. Wallets are accessed using cleos.
账号:用于标记一个发送者或接受者。具有灵活的鉴权结构。
2、安装遇到的问题
mac环境。操作系统:macOS Mojave 版本号:10.14.6
2.1 安装eosio报错
现象:
SummerdeMacBook-Pro:eos summer$ brew install eosio
==> Installing eosio from eosio/eosio
==> Downloading https://github.com/eosio/eos/releases/download/v2.0.0/eosio-2.0.0.mojave.bottle.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/87335980/c7b50e80-33cf-11ea-8fdb-b2062f03be5e?X-Amz-Algorithm=AWS4-HMAC-S
############################# 40.7%
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
curl: (22) The requested URL returned error: 403 Forbidden
Error: Failed to download resource "eosio"
Download failed: https://github.com/eosio/eos/releases/download/v2.0.0/eosio-2.0.0.mojave.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://github.com/eosio/eos/archive/v2.0.0.tar.gz
Already downloaded: /Users/summer/Library/Caches/Homebrew/downloads/50cf9a376f0d6a9af0a5a1a253a0ee5cb8d32bdb697e2ff029d25e181e5e72d5--eos-2.0.0.tar.gz
Warning: Cannot verify integrity of 50cf9a376f0d6a9af0a5a1a253a0ee5cb8d32bdb697e2ff029d25e181e5e72d5--eos-2.0.0.tar.gz
A checksum was not provided for this resource.
For your reference the SHA-256 is: 2346e2356094b21f996460d7c72f48f9b19519a199d3ba6fe39086ab10a5ae4d
Error: An exception occurred within a child process:
RuntimeError: Error, only supporting binary packages at this time
SummerdeMacBook-Pro:eos summer$
原因:网络原因,导致下载eosio-2.0.0.mojave.bottle.tar.gz报错。
解决:手动下载,并且拷贝到brew的缓存目录中。参考https://segmentfault.com/a/1190000020125374
2.2 安装cdt报错
安装cdt相对费劲,cdt有点大,并且还有各种依赖。最后通过梯子安装成功了。不再赘述。
3、概念理解
3.1 eos理解
包括keosd、nodeos和cleos三大模块。
需要分别启动keosd和nodeos进程。nodeos通过命令行或者ini配置文件作为启动参数,nodeos是插件化结构,可以指定自己需要的各种plugin。
默认config和data目录:~/Library/Application Support/eosio/nodeos
3.2 钱包
钱包是用来存储私钥和对交易进行签名的。理解钱包和密钥的概念,创建钱包后,需要导入密钥,导入后,密钥才和钱包对应起来。
大概流程:创建、打开、解锁、导入密钥、导入开发密钥
以下是导入密钥命令,会返回一个公钥,后续创建账号时会用到这个公钥。
SummerdeMacBook-Pro:eos summer$ cleos wallet create_key
Warning: Failed to set locale category LC_NUMERIC to en_CN.
Warning: Failed to set locale category LC_TIME to en_CN.
Warning: Failed to set locale category LC_COLLATE to en_CN.
Warning: Failed to set locale category LC_MONETARY to en_CN.
Warning: Failed to set locale category LC_MESSAGES to en_CN.
Created new private key with a public key of: "EOS53LfJ76o1ppN1i77EwLBaZJ5tuGuf9NLdNxPK2gRpL17LaqFvV"
3.2 账号
创建账号
查看账号
账号(account): 一个可读的字符串,表示交易的接收者和发送者。是一个鉴权集合,一个账号可以由一个个体控制,也可以由多个个体共同控制,通过权重和阈值实现。默认包括owner和active两种permissions。建议ower的私钥冷存储。
权限(permissions):用于指定一个可执行的action。一个权限可以由一个或多个密钥对控制
密钥(keys):公私密钥对
参考:https://developers.eos.io/eosio-nodeos/docs/accounts-and-permissions