如何在Aptos链上发行coin?

icodezjb
发布于 阅读 1072

简介

aptos-cli进行coinmint,burn,transferquery

1. 前置条件

  • 已安装aptos-cli下载链接

  • 测试账户有APT(本文用了2个测试账户):

    • owner(以下交易的默认账户): 用来publish资产合约, mintburn资产合约中的资产.
    private_key: "0x1d5c699949317f8b41f31ddff29332943b1c31dd916e1b6747f408852e25f16f"
    public_key: "0x027b9579c66cbfae60651b7c5f41fcb65eff5e229f29503f17f1eb0780981b89"
    account: d02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f
    
    • receiver: 用来接收资产合约中的资产
    private_key: "0xc43f88efcf5b14dc9ba00f3d73e8a455df260e730133fcd81386df1d463d0332"
    public_key: "0x9a6c8012d9ac973e976cb85d15f611da4f32f95cf0f55e9bf7e03c2fc347bcd1"
    account: 2e39b3b448114792d41ea4ee26f536595a001f734f94b5bd56ae3de6c3096cb0
    

2. 资产合约

源码链接

module mycoin::Coins {
    struct TestCoin {}

    struct XBTC {}

    struct XETH {}
}

3. 合约部署

publish by owner

aptos move publish \
    --named-addresses mycoin=0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f

4. 合约操作

(1) initialize by owner

aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"Test Coin" string:"Test" u8:8 bool:true \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin

(2) register for owner

aptos move run --function-id 0x1::managed_coin::register \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin

(3) mint to owner

aptos move run --function-id 0x1::managed_coin::mint \
    --args address:0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f u64:10000 \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin

(3) only burn from owner

aptos move run --function-id 0x1::managed_coin::burn \
    --args u64:1000 \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin

(4) register for receiver

aptos move run --function-id 0x1::managed_coin::register \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin \
    --private-key 0xc43f88efcf5b14dc9ba00f3d73e8a455df260e730133fcd81386df1d463d0332

(5) mint to receiver by owner

aptos move run --function-id 0x1::managed_coin::mint \
    --args address:0x2e39b3b448114792d41ea4ee26f536595a001f734f94b5bd56ae3de6c3096cb0 u64:10000 \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin

(6) transfer from receiver to owner

aptos move run --function-id 0x1::coin::transfer \
    --args address:0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f u64:111 \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::TestCoin \
    --private-key 0xc43f88efcf5b14dc9ba00f3d73e8a455df260e730133fcd81386df1d463d0332

(7) query the coin

# query owner
aptos account list --account 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f
# quert receiver
aptos account list --account 0x2e39b3b448114792d41ea4ee26f536595a001f734f94b5bd56ae3de6c3096cb0

5. XBTCXETH的操作同上

aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"XBTC" string:"XBTC" u8:8 bool:true \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::XBTC

aptos move run \
    --function-id 0x1::managed_coin::initialize \
    --args string:"XETH" string:"XETH" u8:18 bool:true \
    --type-args 0xd02617efb7147fc1b313d6a6feadef2fc5b21e38268cea50f51ec2222ae64a2f::Coins::XETH
4条评论
cris
cris
速度飞机失联客机 速度离开房间老师看到 谁来的快放假了
点赞
评论
dsa
能搞一个在sui上发coin的教程吗
点赞
评论
Apollo
Apollo
好腻害
点赞
评论
feilun-feilun
feilun-feilun
👍
点赞 1
评论