美文网首页
EOSIO开发(二)智能合约---代币发放

EOSIO开发(二)智能合约---代币发放

作者: JC86 | 来源:发表于2018-07-12 19:25 被阅读0次

    启动 eos-dev docker命令

    sudo docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev  /bin/bash -c "nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console"
    

    进入eosio实例docker容器

    docker exec -it eosio /bin/bash
    
    vim config.ini
    

    找eosio账户公私钥,下步需要用到
    signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

    创建钱包

    cleos wallet create  #默认名字为default
    

    创建钱包wbs

    cleos wallet create -n wbs
    

    解锁

    cleos wallet unlock -n wbs
    

    导入初始账户eosio的主秘钥到钱包 (重要)

    cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 -n wbs
    

    5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3为eosio账户私钥

    cleos set contract eosio contracts/eosio.bios -p eosio
    

    创建秘钥

    cleos create key
    

    导入私钥到钱包

    cleos wallet import -n wbs ${key private}
    

    创建账户user(cleos create account eosio user {key public}{key public})

    cleos create account eosio user EOS8kMHKYgSNqEurP8cGFTbGh5H9wnqvdvpgeruGUWX8iyUpjAQTG EOS8kMHKYgSNqEurP8cGFTbGh5H9wnqvdvpgeruGUWX8iyUpjAQTG
    

    创建账户eosio.token

    cleos create account eosio eosio.token EOS8kMHKYgSNqEurP8cGFTbGh5H9wnqvdvpgeruGUWX8iyUpjAQTG EOS8kMHKYgSNqEurP8cGFTbGh5H9wnqvdvpgeruGUWX8iyUpjAQTG
    

    创建账户test

    cleos create account eosio tester EOS8kMHKYgSNqEurP8cGFTbGh5H9wnqvdvpgeruGUWX8iyUpjAQTG EOS8kMHKYgSNqEurP8cGFTbGh5H9wnqvdvpgeruGUWX8iyUpjAQTG
    

    使用账户eosio.token部署eosio.token智能合约

    cleos set contract eosio.token contracts/eosio.token -p eosio.token
    

    创建一个基于EOS的代币

    cleos push action eosio.token create '[ "eosio", "1000000000.0000 EOS", 0, 0, 0]' -p eosio.token
    

    发放代币到user账户

    cleos push action eosio.token issue '["user","100.0000 EOS", "memo"]' -p eosio
    

    从user账户转代币到tester账户

    cleos push action eosio.token transfer '["user","tester","25.0000 EOS", "m"]' -p user
    

    只看交易情况,不打block

    cleos push action eosio.token issue '["user","100.0000 EOS", "memo"]' -p eosio -d -j
    

    查看余额

    cleos get currency balance eosio.token user EOS
    cleos get currency balance eosio.token tester EOS
    

    参考:
    docker: https://developers.eos.io/eosio-nodeos/docs/docker-quickstart
    代币例子: https://www.cnblogs.com/Evsward/p/eos-contract.html

    相关文章

      网友评论

          本文标题:EOSIO开发(二)智能合约---代币发放

          本文链接:https://www.haomeiwen.com/subject/drwrpftx.html