笔记マップ:Move on Aptos 春季トレーニングキャンプ
環境のインストール#
- rust 環境
 
検証:コマンドラインに cargo と入力
- aptos move 環境
 
https://aptos.dev/tools/aptos-cli/use-cli/use-aptos-cli
検証:コマンドラインに aptos と入力
Windows 環境変数の設定
ショートカットキー win + R を押し、sysdm.cpl と入力して System Properties を開く
Advanced を選択し、下部の Environment Variables... を開く
プロジェクトの作成#
- move プロジェクトの初期化
 
aptos move init —name lesson1
- アカウントの初期化
 
aptos init
プロジェクトの構造
│ Move.toml// プロジェクトの設定、プロジェクト名、プロジェクトアドレス、サードパーティパッケージなど
├─ .aptos// モジュールが指すアカウントとプロジェクトの設定情報
│ config.yaml
├─ scripts // スクリプトファイル、モジュールの呼び出しに使用(あまり使用されない)
├─ sources // モジュールフォルダ、モジュールとテストをここに配置できる
└─ tests // テストファイル、テストケースを書くために使用(あまり使用されない)
Config.yaml#
- 
private_key: アカウントの秘密鍵
 - 
public_key: アカウントの公開鍵
 - 
account: アカウント
 - 
rest_url: ノードのアドレス
 - 
faucet_url: 蛇口のアドレス
 
アカウントが作成されると、テストチェーン上のトークンが手数料として自動的に受け取られます
Move.yaml#
- 
[package]: プロジェクト情報
 - 
[addresses]: アドレスのグローバル変数
 - 
[dev-addresses]: テストアドレス変数
 - 
[dependencies.AptosFramework]: 依存関係
 - 
[dev-dependencies]: テストの依存関係
 
Helloworld プロジェクト#
sources フォルダに main.move ファイルを作成:
module Lesson1::HelloWorld{
    use std::debug::print;
    use std::string::utf8; //Move doesn't support String type, you need to introduce string.
    #[test]
    fun test_hello_world(){
        print(&utf8(b"Hello World")); //
        /*
        1. Strings are not recognized and need to be preceded by a b, meaning converted to bytes.
        2. & var, for read-only, & mut var, for readable and writable
        */
    }
}
注意事項はコメントに記載されており、コメントには日本語の文字を書くことはできません。そうしないとコンパイルエラーが発生します。
コードを保存した後、aptos init を使用してコンパイルします
aptos move test を使用して実行します
コンソールに Hello World が出力されます