获取代码
从EOSIO官方github克隆代码到本地
git clone https://github.com/EOSIO/eos --recursive
如果克隆时没有带--recursive,可以在克隆完成之后进入到工程路径下执行下面的命令来加载子模块。
$ git submodule update --init --recursive
执行安装脚本
进入~/eos目录下,执行./script/eosio_build.sh。
=====================================================================================
========================== Starting EOSIO Installation ==============================
make: *** No rule to make target `install'. Stop.
xx-iMac:eos xxxxx$ ./scripts/eosio_build.sh
EOSIO Version: 1.8.0
xxxx年 x月 x日 星期六 xx时xx分xx秒 UTC
User: xxxxx
Current branch: master
No installation location was specified. Please provide the location where EOSIO is installed.
Do you wish to use the default location? /Users/xxxxx/eosio/1.8? (y/n) y
EOSIO will be installed to: /Users/xxxxx/eosio/1.8
使用默认路径继续
[Ensuring xcode-select installation]
- xcode-select installation found @ /usr/bin/xcode-select
[Ensuring Ruby installation]
- Ruby installation found @ /usr/bin/ruby
[Ensuring HomeBrew installation]
- HomeBrew installation found @ /usr/local/bin/brew
[Ensuring HomeBrew dependencies]
- cmake NOT found.
- graphviz NOT found.
- libtool NOT found.
- automake NOT found.
- wget NOT found.
- gmp found!
- llvm@4 NOT found.
- pkgconfig NOT found.
- python found!
- python@2 NOT found.
- doxygen NOT found.
- libusb found!
- openssl found!
Do you wish to install missing dependencies? (y/n) y
输入y继续,这时会提示是否更新HomeBrew,随便选择,然后继续。
Do you wish to update HomeBrew packages first? (y/n)
安装完成
_______ _______ _______ _________ _______
( ____ \( ___ )( ____ __ __ ( ___ )
| ( \/| ( ) || ( \/ ) ( | ( ) |
| (__ | | | || (_____ | | | | | |
| __) | | | |(_____ ) | | | | | |
| ( | | | | ) | | | | | | |
| (____/\| (___) |/\____) |___) (___| (___) |
(_______/(_______)\_______)\_______/(_______)
=============================================
EOSIO has been successfully built. 0:37:56
You can now install using: ./scripts/eosio_install.sh
Uninstall with: ./scripts/eosio_uninstall.sh
If you wish to perform tests to ensure functional code:
cd ./build && make test
EOSIO website: https://eos.io
EOSIO Telegram channel: https://t.me/EOSProject
EOSIO resources: https://eos.io/resources/
EOSIO Stack Exchange: https://eosio.stackexchange.com
进入eos/programs/ 执行sudo make install,输入密码。
至此完成。
钱包
-
创建默认钱包并输出密码等信息到控制台
cleos wallet create --to-console -
指定钱包名(walletName)创建
cleos wallet create -n walletName --to-console"/usr/local/Cellar/eosio/1.8.0/opt/eosio/bin/keosd" launched Creating wallet: wallet1 Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable. "PW5J2PX3YgixGrXTxx7Exbas6G8LpMs3ivmKnxMq1pCN9SAExEEtbD" -
查看钱包列表
cleos wallet listWallets: [ "wallet1" ]钱包名后没有带*,表示钱包没有解锁,需要去解锁,解锁之后再次查看列表会带*号。
-
锁定钱包
cleos wallet lock -n wallet1不加
-n参数时,默认操作的是default钱包,如果没有创建default钱包,会报错。 -
解锁钱包
cleos wallet unlock -n wallet1命令执行之后,需要输入钱包密码,即创建钱包时在控制台上面打印出来的密码。
-
创建密钥
-
创建密钥并导入指定钱包
cleos wallet create_key -n wallet1Created new private key with a public key of: "EOS7Ax6wBqpMq2WzRW7qGqN1cfebkXvusxVn7K5MUQ7QXhouVEFCB" -
先创建密钥对,然后手动导入钱包
-
先创建
cleos create key --to-consolePrivate key: 5Kf6vtqneyGbTexGvxc6QcxDbcvCgMzxxFXMiJZ7jAaAC3xwS4vC Public key: EOS5ueXfvwvQSF3zEAnpr7T4QXPGok3LnDNkq6jHp6zxWvTuKrnst -
再导入
cleos wallet import -n wallet1 --private-key 5Kf6vtqneyGbTexGvxc6QcxDbcvCgMzxxFXMiJZ7jAaAC3xwS4vCimported private key for: 5Kf6vtqneyGbTexGvxc6QcxDbcvCgMzxxFXMiJZ7jAaAC3xwS4vC
-
-
-
查看钱包中的密钥对
cleos wallet private_keys -n wallet1[ "EOS5ueXfvwvQSF3zEAnpr7T4QXPGok3LnDNkq6jHp6zxWvTuKrnst", "5Kf6vtqneyGbTexGvxc6QcxDbcvCgMzxxFXMiJZ7jAaAC3xwS4vC" ],[ "EOS7Ax6wBqpMq2WzRW7qGqN1cfebkXvusxVn7K5MUQ7QXhouVEFCB", "5KGd9owcPQL64qBxxxxxxx3nM3DMcxxxxyMum74CFPgmawqkLrp" ]
本地节点
-
启动私有节点
nodeos -e -p eosio \ --plugin eosio::producer_plugin \ --plugin eosio::chain_api_plugin \ --plugin eosio::http_plugin \ -d ./eosData \ --config-dir ./eosData/config \ --access-control-allow-origin=* \ --contracts-console \ --http-validate-host=false \ —filter-on=‘*’或
./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin当看到正常出块时,表示节点启动成功。
info 2019-07-06T06:50:23.004 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 000000071404691b... #7 @ 2019-07-06T06:50:23.000 signed by eosio [trxs: 0, lib: 6, confirmed: 0] info 2019-07-06T06:50:23.500 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 0000000807fa0497... #8 @ 2019-07-06T06:50:23.500 signed by eosio [trxs: 0, lib: 7, confirmed: 0] info 2019-07-06T06:50:24.003 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 00000009b09e33a3... #9 @ 2019-07-06T06:50:24.000 signed by eosio [trxs: 0, lib: 8, confirmed: 0] info 2019-07-06T06:50:24.503 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 0000000a9ad6af86... #10 @ 2019-07-06T06:50:24.500 signed by eosio [trxs: 0, lib: 9, confirmed: 0] info 2019-07-06T06:50:25.003 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 0000000b885d17a5... #11 @ 2019-07-06T06:50:25.000 signed by eosio [trxs: 0, lib: 10, confirmed: 0] info 2019-07-06T06:50:25.502 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 0000000cd1dbc1d3... #12 @ 2019-07-06T06:50:25.500 signed by eosio [trxs: 0, lib: 11, confirmed: 0] info 2019-07-06T06:50:26.003 thread-0 producer_plugin.cpp:1865 produce_block ] Produced block 0000000d9f353172... #13 @ 2019-07-06T06:50:26.000 signed by eosio [trxs: 0, lib: 12, confirmed: 0] -
关闭节点
在出块的终端内,使用快捷键
ctrl+z,停止nodeos运行。然后使用jobs命令,查看被挂起的应用,获取nodeeos的后台id。然后使用kill %1,终止后台应用。xxx-iMac:nodeos xxxxxx$ jobs [1]- Running keosd & [2]+ Exit 254 nodeos -e -p eosio --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --access-control-allow-origin='*' --contracts-console --http-validate-host=false --verbose-http-errors >> nodeos.log 2>&1 xxx-iMac:nodeos xxxxxx$ kill 254 xxx-iMac:nodeos xxxxxx$ jobs [1]+ Running keosd & -
检查节点是否有效
在本地浏览器打开
http://localhost:8888/v1/chain/get_info。看是否能正常访问。{ "server_version": "eb88d033", "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f", "head_block_num": 34, "last_irreversible_block_num": 33, "last_irreversible_block_id": "00000021c4b2a3c5010d8653319a675c2403474f261565e347af869a822080ac", "head_block_id": "0000002285e6fd478602e28d157a6dd09472b9d8726eec78b7e659687f4d53fd", "head_block_time": "2019-07-06T07:11:45.000", "head_block_producer": "eosio", "virtual_block_cpu_limit": 206699, "virtual_block_net_limit": 1083756, "block_cpu_limit": 199900, "block_net_limit": 1048576, "server_version_string": "v1.8.0", "fork_db_head_block_num": 34, "fork_db_head_block_id": "0000002285e6fd478602e28d157a6dd09472b9d8726eec78b7e659687f4d53fd" }
创建测试账号
在创建测试账号之前需要先把系统默认账号eosio的私钥导入钱包,否则的话会遇到如下错误
Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
Error Details:
transaction declares authority '${auth}', but does not have signatures for it.
每一个新的EOSIO区块链都有一个默认的系统账号eosio。该账户被用来初始化区块链的设置。每一个新的EOSIO链都内置一个相同的开发密钥5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3。
关于修改eosio默认密钥可以查看:
导入eosio默认私钥
yans-iMac:LocalWallet yannmm$ cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 -n wallet1
imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
创建新的EOS账号
xxx-iMac:LocalWallet xxxxxx$ cleos create account eosio bob EOS6rq8g7C2B9HARuWX8mqT1YH6hBui1Lkg6cvPJk6DLTBHxeXg2N
executed transaction: 96d6abf2721585d3180bfd8d9c57410fba880c9de74e499fac64120682ea6a9e 200 bytes 509 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"bob","owner":{"threshold":1,"keys":[{"key":"EOS6rq8g7C2B9HARuWX8mqT1YH6hB...
warn 2019-07-06T07:33:31.714 thread-0 main.cpp:495 print_resuwarning: transaction executed locally, but may not be confirmed by the network yet
测试账号创建成功✌️
参考
Error 3090003: provided keys, permissions, and delays do not satisfy declared authorizations Ensure