Move.

Post

Share your knowledge.

mssoni.
Feb 17, 2025
Expert Q&A

How to call a function from another Move contract?

I've deployed a contract with an address 0x3df... and a public function 'coll'. Now, I'm trying to write another contract that calls this 'coll' function, but I'm getting an error saying 'use 0x3df...::coll; use is invalid. Unbound module'. I've seen suggestions about using a dependencies file but I'm not sure how to implement this properly. What steps should I take to resolve the error and successfully call the function?

  • Move CLI
  • Move
1
2
Share
Comments
.

Answers

2
Raju.
Feb 17 2025, 15:37

To call a function from another Move contract, you need the source code of the first package. If it's available locally or on GitHub, you should add it in the Move.toml file as a local dependency. When you published your first package, a Move.lock file was created which contains the package's published address. This address will be used in your other project that depends on this published package. Here's a resource for setting up dependencies: Move Book on Manifest.

1
Comments
.
Michelle .
Feb 17 2025, 15:37

Make sure you have set up your local dependencies correctly. Instead of directly using 'use 0x3df...::coll;', you should ensure that the first package is properly integrated. The error you're seeing generally suggests that the module isn't recognized because it's not correctly linked in your dependencies.

0
Comments
.

Do you know the answer?

Please log in and share it.

We use cookies to ensure you get the best experience on our website.
More info