本地兼容Aptos Framework版本测试指引

本文的目的是说明测试 Starcoin 新版本的操作教程

new_framework_1.0.1

安装包: https://github.com/starcoinorg/starcoin/releases/tag/new_framework_1.0.1

  1. 下载解压,检查文件存在:mpm,starcoin

  2. 启动命令行执行指令启动

    starcoin -n dev --disable-mint-empty-block false console

 

测试用户

在starcoin控制台检查默认用户,等待一定时间后会默认获得出块奖励的STC

starcoin % account show { "ok": { "account": { "address": "0x027439000f98b69c120219cda049b950", "is_default": true, "is_locked": true, "is_readonly": false, "public_key": "0xfebf22df32e9a290d675d133a5e33c40665ecc0ec52e4d85ee96487d0604969a", "receipt_identifier": "stc1pqf6rjqq0nzmfcyszr8x6qjde2qdwfm6f" }, "auth_key": "0x0113f889a0564cb2a70991988a2962fb027439000f98b69c120219cda049b950", "balances": { "0x00000000000000000000000000000001::starcoin_coin::STC": 1691501000000 }, "sequence_number": 0 } }

测试转账

# 创建一个账户,需要输入一个创建密码,密码可以为空 account create -p '' { "ok": { "address": "0xaf7fa8093f98a57c54148274b26aeda3", "is_default": false, "is_locked": false, "is_readonly": false, "public_key": "0xc33e460a702a3fcb454bd3ed83dd07b18dec4251e6b0554293e4001869921b22", "receipt_identifier": "stc1p4al6szflnzjhc4q5sf6ty6hd5vdffk2n" } } # 转账之前先解锁账户 account unlock # 转账 account transfer --blocking -r 0xaf7fa8093f98a57c54148274b26aeda3 -v 10000 { "ok": { "dry_run_output": { "events": [ { "data": "0x000000000000000000000000000000010d73746172636f696e5f636f696e03535443", "event_key": { "account_address": "0xaf7fa8093f98a57c54148274b26aeda3", "creation_number": 0 }, "event_seq_number": "0", "type_tag": "0x1::account::CoinRegisterEvent" }, { "data": "0x1027000000000000", "event_key": { "account_address": "0x027439000f98b69c120219cda049b950", "creation_number": 3 }, "event_seq_number": "0", "type_tag": "0x1::coin::WithdrawEvent" }, { "data": "0x1027000000000000", "event_key": { "account_address": "0xaf7fa8093f98a57c54148274b26aeda3", "creation_number": 2 }, "event_seq_number": "0", "type_tag": "0x1::coin::DepositEvent" }, { "data": "0xd3ab170000000000", "event_key": { "account_address": "0x027439000f98b69c120219cda049b950", "creation_number": 3 }, "event_seq_number": "1", "type_tag": "0x1::coin::WithdrawEvent" } ], "explained_status": "Executed", # 操作成功 ... } # 查看转账的额度 account show 0xaf7fa8093f98a57c54148274b26aeda3 { "ok": { "account": { "address": "0xaf7fa8093f98a57c54148274b26aeda3", "is_default": false, "is_locked": true, "is_readonly": false, "public_key": "0xc33e460a702a3fcb454bd3ed83dd07b18dec4251e6b0554293e4001869921b22", "receipt_identifier": "stc1p4al6szflnzjhc4q5sf6ty6hd5vdffk2n" }, "auth_key": "0xb2f62205a14d41605e33f95ce9541372af7fa8093f98a57c54148274b26aeda3", "balances": { "0x00000000000000000000000000000001::starcoin_coin::STC": 10000 # 收到了10000 }, "sequence_number": 0 } }

 

测试部署helloworld合约

将以下文件包解压到任意目录,把根目录下的Move.toml的账户地址改成上面的主账户中的地址
Move工程包:

  1. 在basic目录下执行打包命令

    mpm release
  2. 若打包成功,会生成文件 release/basic-v0.1.0.blob

  3. 在starcoin 控制台执行以下命令部署

    dev deploy <path>/release/basic.v0.1.0.blob { ... ///确保输出中有executed信息 }
  4. 测试一下当前的部署合约的方法

    # 这里需要将0x027439000f98b69c120219cda049b950换成你本机的默认账户地址 # 这里默认设置了一个100 account execute-function -s 0x027439000f98b69c120219cda049b950 --function 0x027439000f98b69c120219cda049b950::basic::initialize --arg 100u64 -b { ... ///确保输出中有executed信息 } # 检查默认账户中是否有对应的resource信息 state list resource 0x027439000f98b69c120219cda049b950 { ... "0x27439000f98b69c120219cda049b950::basic::Basic": { "json": { "value": 100 // 传入的100值 }, "raw": "0x6400000000000000" } ... }