module jyunth_addr::Sample1 {
    use std::debug::print;
    use std::string::{String, utf8};
 
    const ID: u64 = 100;
 
    fun set_value(): u64 {
        let value_id: u64 = 200;
        let string_val: String = utf8(b"jheyanth");
        print(&string_val);
        print(&value_id);
        ID
    }
  
    #[test]
    fun test_function() {
        let id_value = set_value();
        print(&id_value);
    }
}

What did we learn here?

  • mkdir and cd into your project folder.

  • Make a new project using the aptos move init --name (your name) command.

  • Generate a wallet on the devnet using aptos init command.

  • Check the config.yaml file in the .aptos folder for the wallet details.

  • Declare jyunth_addr in the Move.toml file with the account attribute of the owner wallet.

  • Make a new move contract in the sources folder of the project.

  • All modules are tied to a wallet, which lets a single wallet make multiple modules. So in the first line, we declare the owner address (using jyunth_addr) and then the name of the module we are making (Sample1)

  • The standard library is literally stored in the first address (0x1) so we can use it in our module by the use command.

  • Here we need the debug and string classes, so we import them using the appropriate commands.

  • To import multiple functions from the same class, just use the curly brackets as shown.