网友发帖:
EOS3.0 智能合约使用指南。
发表于 昨天17:45|显示全部楼层
EOSIO 3.0 使用指南
运行本地节点
方法1
nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin
方法2
step1:运行nodeos,节点会创建nodeos的config.ini 文件,文件地址可能在两个地方:
eos/build/etc/node_00/~/.local/share/eosio/nodeos/config/
step2: 更改config文件,然后运行nodeos,就可以正常运行。
创建钱包
创建钱包的操作跟2.0一样,这里就不再多说基本的步骤:
cleos wallet create -n wallet_name //创建钱包
cleos wallet import -n wallet_name key //导入私匙
cleos wallet open -n wallet_name //
cleos wallet unlock -n wallet_name --password password
cleso wallet lock_all
cleos wallet lock -n wallet_name
使用系统默认的eosio.bios合约
现在我们有一个带有eosio加载密钥的钱包,我们可以设置默认的系统合同。 为了开发目的,可以使用默认的eosio.bios合约。 此合约使您可以直接控制其他帐户的resoruce分配并访问其他特权api调用。 在公共区块链中,该合同将管理令牌的放样和取消操作,以预留cpu和网络活动的带宽以及合同的内存。
执行结果如下:
lome@lome:~/eos/build$ cleos set contract eosio contracts/eosio.bios -p eosio
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: 0bb7ae021dffb931200c20ed6f4cb81fefd089bebbce7346cf41c86e554f57f64068 bytes10000 cycles
# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001ab011960037f7e7f0060057f7e7e7e...
# eosio <= eosio::setabi{"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...
创建账户
创建账户的代码跟2.0也是一样的:
lome@lome:~/eos/build$ cleos create account eosio lome EOS5sU4bj1UhjNNLzP4CYmmoHPm9rpUkqX74ra5FiFwBGwznHt59P EOS5sU4bj1UhjNNLzP4CYmmoHPm9rpUkqX74ra5FiFwBGwznHt59P
executed transaction: 957e5d8ff2e9d98db6ba6e1efc6dc6e2e57e1123ff81f78cadf6bf9fa11ef4ea364 bytes1000 cycles
# eosio <= eosio::newaccount{"creator":"eosio","name":"lome","owner":{"threshold":1,"keys":[{"key":"EOS5sU4bj1UhjNNLzP4CYmmoHPm9...
通过key获取账户
1.在创建一个账户:
lome@lome:~/eos/build$ cleos create account eosio lome2 EOS5sU4bj1UhjNNLzP4CYmmoHPm9rpUkqX74ra5FiFwBGwznHt59P EOS5sU4bj1UhjNNLzP4CYmmoHPm9rpUkqX74ra5FiFwBGwznHt59P
executed transaction: deab457f2c4f4e98f7447fd87ccb92149766f809dcd3577525e03c87fa4d55c5364 bytes1000 cycles
# eosio <= eosio::newaccount{"creator":"eosio","name":"lome2","owner":{"threshold":1,"keys":[{"key":"EOS5sU4bj1UhjNNLzP4CYmmoHPm...
2. 获取使用该密匙的账户:
lome@lome:~/eos/build$ cleos get accounts EOS5sU4bj1UhjNNLzP4CYmmoHPm9rpUkqX74ra5FiFwBGwznHt59P
{
"account_names": [
"lome",
"lome2"
]
}
创建一个token 合约
1. 创建账户
lome@lome:~/eos/build$ cleos create account eosio eosio.token EOS8mvgDwRv8kiX213BN38UeTE8ga2TckKyKUaAGzE3LguCKVETzu EOS8mvgDwRv8kiX213BN38UeTE8ga2TckKyKUaAGzE3LguCKVETzu
executed transaction: 2cd3d9266a5cf250c7d8900eacfa16c58791b5c442c305fe90d32743bfe11af2364 bytes1000 cycles
# eosio <= eosio::newaccount{"creator":"eosio","name":"eosio.token","owner":{"threshold":1,"keys":[{"key":"EOS8mvgDwRv8kiX213BN3...
2. 部署合约
lome@lome:~/eos/build$ cleos set contract eosio.token contracts/eosio.token -p eosio.token