三战EOS合约

时间:2018.4.8

对应github文档

先执行脚本eosio_build.sh 

./eosio_build.sh  

成功后会出现

[100%] Built target nodeos


	 _______  _______  _______ _________ _______
	(  ____ \(  ___  )(  ____ \\__   __/(  ___  )
	| (    \/| (   ) || (    \/   ) (   | (   ) |
	| (__    | |   | || (_____    | |   | |   | |
	|  __)   | |   | |(_____  )   | |   | |   | |
	| (      | |   | |      ) |   | |   | |   | |
	| (____/\| (___) |/\____) |___) (___| (___) |
	(_______/(_______)\_______)\_______/(_______)

	EOS.IO has been successfully built. 0:4:49

	To verify your installation run the following commands:

	/home/feng/opt/mongodb/bin/mongod -f /home/feng/opt/mongodb/mongod.conf &
	cd /home/feng/eos/build; make test

	For more information:
	EOS.IO website: https://eos.io
	EOS.IO Telegram channel @ https://t.me/EOSProject
	EOS.IO resources: https://eos.io/resources/
	EOS.IO wiki: https://github.com/EOSIO/eos/wiki

到nodes目录执行下

$ nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin 

然后ctrl c推出,在config.ini文件目录下,修改配置

cd ~/.local/share/eosio/nodeos/config
sudo gedit config.ini 

修改以下几个点,enable-stale-production,producer-name,plugin

# Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = eosio
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
# This will be used by the validation step below, to view account history
plugin = eosio::account_history_api_plugin

再次运行

$ nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin 
创建钱包
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos wallet create # Outputs a password that you need to save to be able to lock/unlock the wallet
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JnCTLgXUjWxHbBKZbi9qxiJLArGHMZVewe2Vmffc6QFdFWCjps"

为eosio帐号部署合约

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$  ./cleos set contract eosio ../../contracts/eosio.bios -p eosio
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: b548131d0f9b43f35efb9e7b32ea3a68ad129ef60fb6723e5cb31f52a064bee6  4076 bytes  10000 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个key,导入key的私钥

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos create key
Private key: 5KQW3j9A7syYzqddkAmUn61wCUv1oe5fYPUshn9oGzwek9x5zfi
Public key: EOS57B3q6aXGaDgtPUB1duG4fPouQfR9YAwKNjsaiUDcyNTKBfEB8
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos create key
Private key: 5JaPcjSshJgY7LGZdnNRf9rYCE5jmkRjajNd5rz46LeDBbFAY15
Public key: EOS516j4nHog3McrqCajN1WEP1hg8bE6LJjxeXi6gURrmG1CPB2ES
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos wallet import 5KQW3j9A7syYzqddkAmUn61wCUv1oe5fYPUshn9oGzwek9x5zfi
imported private key for: EOS57B3q6aXGaDgtPUB1duG4fPouQfR9YAwKNjsaiUDcyNTKBfEB8
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos wallet import 5JaPcjSshJgY7LGZdnNRf9rYCE5jmkRjajNd5rz46LeDBbFAY15
imported private key for: EOS516j4nHog3McrqCajN1WEP1hg8bE6LJjxeXi6gURrmG1CPB2ES

根据生成的公钥,创建帐号

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos create account eosio currency EOS57B3q6aXGaDgtPUB1duG4fPouQfR9YAwKNjsaiUDcyNTKBfEB8 EOS516j4nHog3McrqCajN1WEP1hg8bE6LJjxeXi6gURrmG1CPB2ES
executed transaction: 23ab19cf405f83a614d35aa00ed1f003c680ffed6aa48e99ff58a77234421c75  364 bytes  1000 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"currency","owner":{"threshold":1,"keys":[{"key":"EOS57B3q6aXGaDgtPUB1duG4...
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos get account currency
{
  "account_name": "currency",
  "permissions": [{
      "perm_name": "active",
      "parent": "owner",
      "required_auth": {
        "threshold": 1,
        "keys": [{
            "key": "EOS516j4nHog3McrqCajN1WEP1hg8bE6LJjxeXi6gURrmG1CPB2ES",
            "weight": 1
          }
        ],
        "accounts": []
      }
    },{
      "perm_name": "owner",
      "parent": "",
      "required_auth": {
        "threshold": 1,
        "keys": [{
            "key": "EOS57B3q6aXGaDgtPUB1duG4fPouQfR9YAwKNjsaiUDcyNTKBfEB8",
            "weight": 1
          }
        ],
        "accounts": []
      }
    }
  ]
}

检测,并部署合约

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos get code currency
code hash: 0000000000000000000000000000000000000000000000000000000000000000
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos set contract currency ../../contracts/currency
Reading WAST...
Assembling WASM...
Publishing contract...
executed transaction: 20b220cc460a0c921bc298be80ee4cc521ff6974be2b6d1c62efa12fdca32380  7820 bytes  10000 cycles
#         eosio <= eosio::setcode               {"account":"currency","vmtype":0,"vmversion":0,"code":"0061736d0100000001dd011f60000060057e7e7e7e7f0...
#         eosio <= eosio::setabi                {"account":"currency","abi":{"types":[{"new_type_name":"account_name","type":"name"}],"structs":[{"n...
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos get code currency
code hash: be74801005e3ce134df5bfff18d1d5afa4c0d1f633a9a5d6e531e2f1b7373710

创建货币

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos push action currency create '{"issuer":"currency","maximum_supply":"1000000.0000 CUR","can_freeze":"0","can_recall":"0","can_whitelist":"0"}' --permission currency@active
executed transaction: ec5fb245922c350650cbdc7dbd8925a2e8249409b4bd7df7dd42044faa34b7ce  260 bytes  1000 cycles
#      currency <= currency::create             {"issuer":"currency","maximum_supply":"1000000.0000 CUR","can_freeze":0,"can_recall":0,"can_whitelis...
>> create

发行货币

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos push action currency issue '{"to":"currency","quantity":"1000.0000 CUR","memo":""}' --permission currency@active
executed transaction: 3b9004be8ecb66b1c1f143928d6cef5724c62984e7de18bb983ae68987f5234f  260 bytes  1000 cycles
#      currency <= currency::issue              {"to":"currency","quantity":"1000.0000 CUR","memo":""}
>> issue

查看帐号信息

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos get table currency currency accounts
{
  "rows": [{
      "balance": "1000.0000 CUR",
      "frozen": 0,
      "whitelist": 1
    }
  ],
  "more": false
}

转账

feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos push action currency transfer '{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active
executed transaction: bcded76874aabd8c2a2974c13815086192a274171281197cd9a376b8e88e52d1  284 bytes  1000 cycles
#      currency <= currency::transfer           {"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}
>> transfer
#         eosio <= currency::transfer           {"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos get table currency eosio accounts
{
  "rows": [{
      "balance": "20.0000 CUR",
      "frozen": 0,
      "whitelist": 1
    }
  ],
  "more": false
}
feng@feng-B250-HD3P:~/workSpace/eos/build/programs/cleos$ ./cleos get table currency currency accounts
{
  "rows": [{
      "balance": "980.0000 CUR",
      "frozen": 0,
      "whitelist": 1
    }
  ],
  "more": false
}

EOS区块链qq群,欢迎大家多多技术交流:695283188


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值