1

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?
TylerH
  • 20,799
  • 66
  • 75
  • 101
Anto
  • 153
  • 1
  • 7

1 Answers1

2

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())

  • Consider extending your answer, specifically in the manifest file, to demonstrate linking to a local directory as well. – Frank C. Sep 29 '22 at 17:02