Finn

Finn

👨🏻‍💻工作:Web3 产品经理 🏙️城市:香港 🧩性格:INFP 最近在做 GameFi,能赚钱的游戏
jike
email

Move on Aptos Spring Training Camp Notes | 01 HelloWorld

Note Map: Move on Aptos Spring Training Camp

Environment Installation#

  1. Rust Environment

https://www.rust-lang.org/

Verification: Enter cargo in the command line

image

  1. Aptos Move Environment

https://aptos.dev/tools/aptos-cli/use-cli/use-aptos-cli

Verification: Enter aptos in the command line

Windows Environment Variable Settings

Shortcut win + R, enter sysdm.cpl to open System Properties

image

Select Advanced, open Environment Variables... at the bottom

image

Create Project#

  1. Initialize Move Project
aptos move init --name lesson1
  1. Initialize Account
aptos init

Project Structure

│ Move.toml // Project configuration, such as project name, project address, third-party packages

├─ .aptos // Account and project configuration information pointed by the module

│ config.yaml

├─ scripts // Script files used to call modules (used less frequently)

├─ sources // Module folder, modules and tests can be placed here

└─ tests // Test files used to write test cases (used less frequently)

Config.yaml#

  • private_key: Account private key

  • public_key: Account public key

  • account: Account

  • rest_url: Node address

  • faucet_url: Faucet address

After creating an account, test tokens on the test chain will be automatically received as transaction fees

Move.yaml#

  • [package]: Project information

  • [addresses]: Address global variables

  • [dev-addresses]: Test address variables

  • [dependencies.AptosFramework]: Dependencies

  • [dev-dependencies]: Test dependencies

Helloworld Project#

Create a main.move file in the sources folder:

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
        */
    }
}

Important notes have been written in the comments, even Chinese characters cannot be written in the comments, otherwise compilation errors will occur.

Save the code and compile it with aptos init

Run it with aptos move test

image

The console will output Hello World

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.