Note Map: Move on Aptos Spring Training Camp
Environment Installation#
- Rust Environment
Verification: Enter cargo
in the command line
- 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
Select Advanced, open Environment Variables... at the bottom
Create Project#
- Initialize Move Project
aptos move init --name lesson1
- 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
The console will output Hello World