Move.

帖子

分享您的知识。

mssoni.
Feb 17, 2025
专家问答

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
分享
评论
.

答案

2
Raju.
Feb 17 2025, 15:37

要调用另一个 Move 合约中的函数,你需要第一个包的源代码. 如果它在本地或在 GitHub 上可用,则应将其作为本地依赖项添加到 move.toml 文件中. 当您发布第一个软件包时,创建了一个 Move.lock 文件,其中包含该软件包的发布地址. 此地址将用于依赖此已发布包的其他项目. 以下是设置依赖项的资源:Move Book on Manifest.

1
评论
.
Michelle .
Feb 17 2025, 15:37

确保您已正确设置本地依赖关系. 而不是直接使用 “使用 0x3df...:: coll; ',你应该确保第一个包已正确集成. 你看到的错误通常表明该模块无法被识别,因为它在你的依赖项中没有正确链接.

0
评论
.

你知道答案吗?

请登录并分享。

我们使用 cookie 确保您在我们的网站上获得最佳体验。
更多信息