您正在查看: Surou 发布的文章

零基础部署测试合约(一)---前准备

经过前面的三步

EOS 节点部署,BP出块(一)-->前期准备
EOS 节点部署,BP出块(二)-->节点连接
EOS 节点部署,BP出块(三)-->开始部署
已经完成了EOS链服务器相关配置,下面开始部署合约相关配置

  1. 打开eosio节点终端,创建dapp.token,dapp.exec账号
账号 公钥 私钥
dapp.token EOS7STj8j1LDXBVhttRm9FiyME1fDDn77UfjsFu1XQ2ybF2sYpwAM 5J87thFoJVD9fNos9i9QvLYFxZqCWMX4xJ3gGUGkweDbEn5WY2d
dapp.exec EOS5rzFj2sd4hmpAco8ujmDMDxZwWWTSvcS5BJYWpCcen6YbtNFAN 5JC9FdRjX3c3fsB62S5Tz22LgTuRHegb1XEV16uft8u3njmm9E5
//导入私钥
cleos wallet import 5J87thFoJVD9fNos9i9QvLYFxZqCWMX4xJ3gGUGkweDbEn5WY2d
cleos wallet import 5JC9FdRjX3c3fsB62S5Tz22LgTuRHegb1XEV16uft8u3njmm9E5
//创建账号
cleos system newaccount eosio dapp.token EOS7STj8j1LDXBVhttRm9FiyME1fDDn77UfjsFu1XQ2ybF2sYpwAM EOS7STj8j1LDXBVhttRm9FiyME1fDDn77UfjsFu1XQ2ybF2sYpwAM  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS' --buy-ram-kbytes 10000
cleos system newaccount eosio dapp.exec EOS5rzFj2sd4hmpAco8ujmDMDxZwWWTSvcS5BJYWpCcen6YbtNFAN EOS5rzFj2sd4hmpAco8ujmDMDxZwWWTSvcS5BJYWpCcen6YbtNFAN  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS' --buy-ram-kbytes 10000
//如果提示 Error 3080001: account using more than allotted RAM usage
cleos system buyram eosio dapp.token '100000.0000 SYS' -p eosio

部署测试合约(二)---合约编译
部署测试合约(三)---合约部署

零基础EOS 节点部署,BP出块(一)-->前期准备

事前准备

  1. 部署3台主机,账户名为(eosio,eosio.bp1,eosio.bp2),系统为Ubuntu 16.04以上版本
  2. 生成15个EOS地址 (10个系统预留账户,2个节点,3个用于投票)(在线生成
eosio eosio.token eosio.bpay eosio.msig eosio.names
eosio.ram eosio.ramfee eosio.saving eosio.stake eosio.upay
eosio.bp1 eosio.bp2 voter1 voter2 voter3
账户名 私钥 公钥
eosio 5KeqsXty9Sa8GfJgNfkckYxKKGcAWE4AWmUHiw6ifDcn3jjUg2i EOS5DkKbBZnSKNSV1iu27ovnygGhoCA99eH69KyNNkSkNrrbBoiRe
eosio.token 5JvL5wbJeQdgpKDDLRFUyWmHwBpRDgvARn99cS4pXoxZt8p7p4w EOS5M2sNqDPZtQoBcRMnPQEnY1MJaVtdWWPx7A3UpcLgtzdLusFVW
eosio.bpay 5KS9q4MPwmcpEM3rX96zR4A4FvLJZC9y1BZxvidaEwqfb4MWREx EOS5iezVa6bsmvZ3HNxdqgyX6GFRMWzE7FsjS3cui8Foavxnj8CfR
eosio.msig 5HsbhVhjtzeuzxdWKQv2MWBtbHzgjxEtYKQg9XB3cxPRYaC7r4m EOS8K1wkfCzPmxAjjfqvqw6zQ1Dbc82YsQyR8MmwNFLcRHcJtth89
eosio.names 5JrEru2K7FKLrwfLQ6B55PRWj2MXVkuXrLiurfn2osSatRsEmj6 EOS5ps938c5zj6UqhdCfssyAy7WSbHgfZoraqD6HrnbpmpEwPwX7S
eosio.ram 5HqNyZgePkdSZLuhz9YTi36L7HuhxpPeEEppNaB49Z7WcJWVsed EOS7DA8jGA6HfZXYcGSGJNsWJL5Q6t5bWcvm4zNykN3Jw7tASzBCR
eosio.ramfee 5KdYWerC5XnqfDhVV5igoyjuNFrT78McrErvbUMd36Wje77t6kJ EOS7R1Ds4zLMPN6onVXjL8XGgKHHCMWjLT7wn3bHcHnQX3dVLErjE
eosio.saving 5JN3GEXZVKYWAgbfdppvGU3hSpiu9BUcpEwpqMMp1NA6gvUsGF9 EOS6BDfFaFZgvx889BQbdaGTMYSn5tUuxaynGQDhpDGD662eBGwkF
eosio.upay 5Kgqr6jB6mfMjNv4vX1Hwj3KqiCxYUhPCnuxTK1mVN118fok4oG EOS7zS7sHctU54oD6is2oPfq11duCMSWfda3HXJAghSfqqr2BZZnV
eosio.bp1 5JzWCZ9W7VNWLYroQpjYG2z6H6UjJUkKdinZpumf6Ru2xoxSrKT EOS7mcXeVUSLCZxEf8eBPm2MbmiswNovoB6rk71pPqaZoxwSAeK7b
eosio.bp2 5HragVTsSmmAg1mznNMDSeAp2ZezcNBw6SbczrNpNtUqRcx4vhh EOS6hfh1yup4tZjbjhD3oPuZwMFqL4iUVehgMsukuvx5ojTWuurtT
voter1 5Jb2DtzYFU9c3LSEP5PPAfN7Je8d8yLGdDN42n561zy34UFwzTN EOS6wLrhcEQDZJvfZSCgVkFzsKcv34XTsTTjXXQZajWaBbEhvLPMg
voter2 5JsFet6W3Xmp3DvcHJsJ6GVcksSZJunGhmjpQaE9Np2ZtK4JYbc EOS6u8i7rknHyAd7AdziWSnEsAbyJHA3U9So4R8p2z58cA1KeEDv2
voter3 5JdQRPPCXtVLKBj5qhg6QtVq5PHuKoKnrcpePG6CsryPuYkiWX6 EOS8LyieKTsMAZGp7DSEhBPEPmPXvQKT5c3EXgEvACcdRwwRwDzoy

EOS 节点部署,BP出块(二)-->节点连接
EOS 节点部署,BP出块(三)-->开始部署

零基础EOS 节点部署,BP出块(三)-->开始部署

1.进入eosio主机终端

//eosio节点创建钱包
cleos wallet create
//保存解锁密钥
PW5K2Rg4rSYanfdcjnMcPhLUKZoBd2rq1W9mDZSoebgmKG55JXugU
//导入eosio帐号私钥
cleos wallet import 5KeqsXty9Sa8GfJgNfkckYxKKGcAWE4AWmUHiw6ifDcn3jjUg2i
//创建 eosio.token
cleos create account eosio eosio.token EOS5M2sNqDPZtQoBcRMnPQEnY1MJaVtdWWPx7A3UpcLgtzdLusFVW EOS5M2sNqDPZtQoBcRMnPQEnY1MJaVtdWWPx7A3UpcLgtzdLusFVW
//导入eosio.token私钥
cleos wallet import 5JvL5wbJeQdgpKDDLRFUyWmHwBpRDgvARn99cS4pXoxZt8p7p4w
//创建系统预留账户
cleos create account eosio eosio.bpay EOS5iezVa6bsmvZ3HNxdqgyX6GFRMWzE7FsjS3cui8Foavxnj8CfR EOS5iezVa6bsmvZ3HNxdqgyX6GFRMWzE7FsjS3cui8Foavxnj8CfR
cleos create account eosio eosio.msig EOS8K1wkfCzPmxAjjfqvqw6zQ1Dbc82YsQyR8MmwNFLcRHcJtth89 EOS8K1wkfCzPmxAjjfqvqw6zQ1Dbc82YsQyR8MmwNFLcRHcJtth89
cleos create account eosio eosio.names EOS5ps938c5zj6UqhdCfssyAy7WSbHgfZoraqD6HrnbpmpEwPwX7S EOS5ps938c5zj6UqhdCfssyAy7WSbHgfZoraqD6HrnbpmpEwPwX7S
cleos create account eosio eosio.ram EOS7DA8jGA6HfZXYcGSGJNsWJL5Q6t5bWcvm4zNykN3Jw7tASzBCR EOS7DA8jGA6HfZXYcGSGJNsWJL5Q6t5bWcvm4zNykN3Jw7tASzBCR
cleos create account eosio eosio.ramfee EOS7R1Ds4zLMPN6onVXjL8XGgKHHCMWjLT7wn3bHcHnQX3dVLErjE EOS7R1Ds4zLMPN6onVXjL8XGgKHHCMWjLT7wn3bHcHnQX3dVLErjE
cleos create account eosio eosio.saving EOS4uDMpca1dAK7HZZRQ1SqWZHvJNnakzsSuTmM12crvzwRorwQcQ EOS4uDMpca1dAK7HZZRQ1SqWZHvJNnakzsSuTmM12crvzwRorwQcQ
cleos create account eosio eosio.stake EOS6BDfFaFZgvx889BQbdaGTMYSn5tUuxaynGQDhpDGD662eBGwkF EOS6BDfFaFZgvx889BQbdaGTMYSn5tUuxaynGQDhpDGD662eBGwkF
cleos create account eosio eosio.upay EOS7zS7sHctU54oD6is2oPfq11duCMSWfda3HXJAghSfqqr2BZZnV EOS7zS7sHctU54oD6is2oPfq11duCMSWfda3HXJAghSfqqr2BZZnV
//切换到contracts目录
cd /eos/build/contracts
//部署eosio.token合约
cleos set contract eosio.token eosio.token
//创建代币 (BM将线上代码EOS 改成了SYS,之后上线后还是EOS)
cleos push action eosio.token create '["eosio","10000000000.0000 SYS",0,0,0]' -p eosio.token
//发布代币
cleos push action eosio.token issue '["eosio","10000000000.0000 SYS","issue"]' -p eosio
//查询代币数量
cleos get currency balance eosio.token eosio
//部署eosio.bios合约
cleos set contract eosio eosio.bios/ -p eosio
//部署eosio.system合约
cleos set contract eosio eosio.system -p eosio
//创建BP节点账户
cleos system newaccount eosio eosio.bp1 EOS7mcXeVUSLCZxEf8eBPm2MbmiswNovoB6rk71pPqaZoxwSAeK7b EOS7mcXeVUSLCZxEf8eBPm2MbmiswNovoB6rk71pPqaZoxwSAeK7b  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS'  --buy-ram-kbytes 10000
cleos system newaccount eosio eosio.bp2 EOS6hfh1yup4tZjbjhD3oPuZwMFqL4iUVehgMsukuvx5ojTWuurtT EOS6hfh1yup4tZjbjhD3oPuZwMFqL4iUVehgMsukuvx5ojTWuurtT  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS'  --buy-ram-kbytes 10000

//创建Voter账户
cleos system newaccount eosio voter1 EOS6wLrhcEQDZJvfZSCgVkFzsKcv34XTsTTjXXQZajWaBbEhvLPMg  EOS6wLrhcEQDZJvfZSCgVkFzsKcv34XTsTTjXXQZajWaBbEhvLPMg  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS'  --buy-ram-kbytes 10000
cleos system newaccount eosio voter2 EOS6u8i7rknHyAd7AdziWSnEsAbyJHA3U9So4R8p2z58cA1KeEDv2  EOS6u8i7rknHyAd7AdziWSnEsAbyJHA3U9So4R8p2z58cA1KeEDv2  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS'  --buy-ram-kbytes 10000
cleos system newaccount eosio voter3 EOS8LyieKTsMAZGp7DSEhBPEPmPXvQKT5c3EXgEvACcdRwwRwDzoy  EOS8LyieKTsMAZGp7DSEhBPEPmPXvQKT5c3EXgEvACcdRwwRwDzoy  --stake-net '50.00 SYS' --stake-cpu '50.00 SYS'  --buy-ram-kbytes 10000
//导入Voter私钥
cleos wallet import 5Jb2DtzYFU9c3LSEP5PPAfN7Je8d8yLGdDN42n561zy34UFwzTN
cleos wallet import 5JsFet6W3Xmp3DvcHJsJ6GVcksSZJunGhmjpQaE9Np2ZtK4JYbc
cleos wallet import 5JdQRPPCXtVLKBj5qhg6QtVq5PHuKoKnrcpePG6CsryPuYkiWX6

//给Voter账户转账
cleos push action eosio.token transfer '["eosio", "voter1","100000000.0000 SYS","vote"]' -p eosio
cleos push action eosio.token transfer '["eosio", "voter2","100000000.0000 SYS","vote"]' -p eosio
cleos push action eosio.token transfer '["eosio", "voter3","100000000.0000 SYS","vote"]' -p eosio
//锁定Voter账户需要投票的代币
cleos system delegatebw voter1 voter2 '25000000.0000 SYS' '25000000.0000 SYS' --transfer
cleos system delegatebw voter2 voter3 '25000000.0000 SYS' '25000000.0000 SYS' --transfer
cleos system delegatebw voter3 voter1 '25000000.0000 SYS' '25000000.0000 SYS' --transfer

2.进入eosio.bp1 主机终端

//BP1节点创建钱包
cleos wallet create
//保存解锁密钥
PW5HsYdyQdQfTgHJnpaiGRjFVDLs7Cb48A6PzeneaDNdSf8UnrntT
//导入私钥
cleos wallet import 5JzWCZ9W7VNWLYroQpjYG2z6H6UjJUkKdinZpumf6Ru2xoxSrKT
//BP1节点申请BP
cleos system regproducer eosio.bp1 EOS7mcXeVUSLCZxEf8eBPm2MbmiswNovoB6rk71pPqaZoxwSAeK7b http://eosio.bp1.ip:8888

3.进入eosio.bp2 主机终端

//BP2节点创建钱包
cleos wallet create
//保存私钥
PW5JaB4WtawXWE6wmDymsprEdh9xPiL5EakY83JDywdvpFbK9fWpG
//导入私钥
cleos wallet import 5HragVTsSmmAg1mznNMDSeAp2ZezcNBw6SbczrNpNtUqRcx4vhh
//BP2申请BP
cleos system regproducer eosio.bp2 EOS6hfh1yup4tZjbjhD3oPuZwMFqL4iUVehgMsukuvx5ojTWuurtT http://eosio.bp2.ip:8888

4.回到eosio主机终端

//BP节点申请BP
cleos system regproducer eosio EOS5DkKbBZnSKNSV1iu27ovnygGhoCA99eH69KyNNkSkNrrbBoiRe http://eosio.eosio.ip:8888

//开始投票
cleos system voteproducer prods voter1 eosio.bp1
cleos system voteproducer prods voter2 eosio.bp1
cleos system voteproducer prods voter3 eosio.bp1
cleos system voteproducer prods voter1 eosio.bp2
cleos system voteproducer prods voter2 eosio.bp2
cleos system voteproducer prods voter3 eosio.bp2

cleos system voteproducer prods voter1 eosio
cleos system voteproducer prods voter2 eosio
cleos system voteproducer prods voter3 eosio

此时 eosio, eosio.bp1, eosio.bp2 已出块

零基础EOS 节点部署,BP出块(二)-->节点连接

1.进入eosio主机终端,

cd ~/.local/share/eosio/nodeos/config
//编辑配置文件
vi config.ini
//修改p2p-server-address 为本机ip
p2p-server-address = 192.168.1.116:9876
//修改初始化创世块
enable-stale-production = true
//修改producer-name 为eosio(创世节点必须此名)
producer-name = eosio
//修改key
private-key = ["EOS5DkKbBZnSKNSV1iu27ovnygGhoCA99eH69KyNNkSkNrrbBoiRe","5KeqsXty9Sa8GfJgNfkckYxKKGcAWE4AWmUHiw6ifDcn3jjUg2i"]
//添加插件支持
plugin = eosio::producer_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::wallet_api_plugin
#plugin = eosio::account_history_api_plugin
plugin = eosio::http_plugin

2.进入 eosio.bp1主机终端

cd ~/.local/share/eosio/nodeos/config
//编辑配置文件
vi config.ini
//修改p2p-server-address 为本机ip
p2p-server-address = 192.168.1.116:9876
//p2p-peer-address 添加 eosio和eosio.bp2 ip
p2p-peer-address = 192.168.1.112:9876
p2p-peer-address = 192.168.1.168:9876
//修改 producer-name
producer-name = eosio.bp1
//修改 key
private-key = ["EOS6hfh1yup4tZjbjhD3oPuZwMFqL4iUVehgMsukuvx5ojTWuurtT","5HragVTsSmmAg1mznNMDSeAp2ZezcNBw6SbczrNpNtUqRcx4vhh"]
//添加插件支持
plugin = eosio::chain_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::producer_plugin
plugin = eosio::http_plugin
plugin = eosio::net_api_plugin
plugin = eosio::net_plugin
plugin = eosio::wallet_api_plugin
plugin = eosio::history_api_plugin

3.进入eosio.bp2主机终端 同2

//注意修改 config.ini
//p2p-peer-address 添加 eosio和eosio.bp1 ip

EOS 节点部署,BP出块(三)-->开始部署

cleos system newaccount failed with “to account does not exist” error message

The following accounts need to be created before you can use eosio.system contract via cleos system newaccount to create accounts:

systemAccounts = [
    'eosio.bpay',
    'eosio.msig',
    'eosio.names',
    'eosio.ram',
    'eosio.ramfee',
    'eosio.saving',
    'eosio.stake',
    'eosio.token',
    'eosio.upay',
]

//创建系统预留账户
cleos create account eosio eosio.bpay EOS5iezVa6bsmvZ3HNxdqgyX6GFRMWzE7FsjS3cui8Foavxnj8CfR EOS5iezVa6bsmvZ3HNxdqgyX6GFRMWzE7FsjS3cui8Foavxnj8CfR
cleos create account eosio eosio.msig EOS8K1wkfCzPmxAjjfqvqw6zQ1Dbc82YsQyR8MmwNFLcRHcJtth89 EOS8K1wkfCzPmxAjjfqvqw6zQ1Dbc82YsQyR8MmwNFLcRHcJtth89
cleos create account eosio eosio.names EOS5ps938c5zj6UqhdCfssyAy7WSbHgfZoraqD6HrnbpmpEwPwX7S EOS5ps938c5zj6UqhdCfssyAy7WSbHgfZoraqD6HrnbpmpEwPwX7S
cleos create account eosio eosio.ram EOS7DA8jGA6HfZXYcGSGJNsWJL5Q6t5bWcvm4zNykN3Jw7tASzBCR EOS7DA8jGA6HfZXYcGSGJNsWJL5Q6t5bWcvm4zNykN3Jw7tASzBCR
cleos create account eosio eosio.ramfee EOS7R1Ds4zLMPN6onVXjL8XGgKHHCMWjLT7wn3bHcHnQX3dVLErjE EOS7R1Ds4zLMPN6onVXjL8XGgKHHCMWjLT7wn3bHcHnQX3dVLErjE
cleos create account eosio eosio.saving EOS4uDMpca1dAK7HZZRQ1SqWZHvJNnakzsSuTmM12crvzwRorwQcQ EOS4uDMpca1dAK7HZZRQ1SqWZHvJNnakzsSuTmM12crvzwRorwQcQ
cleos create account eosio eosio.stake EOS6BDfFaFZgvx889BQbdaGTMYSn5tUuxaynGQDhpDGD662eBGwkF EOS6BDfFaFZgvx889BQbdaGTMYSn5tUuxaynGQDhpDGD662eBGwkF
cleos create account eosio eosio.upay EOS7zS7sHctU54oD6is2oPfq11duCMSWfda3HXJAghSfqqr2BZZnV EOS7zS7sHctU54oD6is2oPfq11duCMSWfda3HXJAghSfqqr2BZZnV

先创建系统预留账户,然后再创建其他账户