move-langdiem

How can I use other published module functions in my move module?


I need to call some other module functions (Those already published modules in aptos blockchain) in my move module.

  1. How can I import those module functions in my module?
  2. How to add that module as a dependency in my Move.toml file?

Solution

  • The dependencies section of your Move.toml allows you to specify packages, such as the Sui package, which needs a pointer to the correct github repository and branch:

    [dependencies]
    Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework", rev = "devnet" }
    

    And then you would import that package and module into your module like so:

    module my_package::my_module {
        use sui::object::{Self, ID, UID};
    }
    

    Where sui is the imported package, object is the imported module, ID, and UID are structs in the module, and Self allows you to reference the module functions (e.g. object::new())