所有模块是否会自动继承硬币合同,还是需要进口?

发布于 2025-01-25 10:26:28 字数 72 浏览 0 评论 0原文

在接受我要赚取的NFT付款时,我如何确保我可以从模块中调用cuin.trans.trans.trans.coin.details?

When accepting payment for an NFT I am making, how do I ensure I can call coin.transfer and coin.details from my module?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌吟 2025-02-01 10:26:28

因此,唯一的每项条件是

  1. 指代硬币合同的
  2. 转移功能

您可以通过执行Coin.transfer等来引用硬币合同的转移功能(呼叫)功能。
您还可以通过在合同中执行(使用Coin)来“导入”整个硬币模块。这会导入硬币合同中的所有功能,因此您可以将它们称为Transfer而不是Coin.transfer
但这可能会导致意外的错误,如果不谨慎使用,我建议您始终将它们称为coin.transfer等,

您需要确保授予“转移”功能。这可以由呼叫者在调用合同时通过 /指定。
如果您的合同是帐户的“所有者”(即合同的余额),则可以使用internapability,该将允许合同授予自己的帐户转让的能力

So the only per-requisites are

  1. Reference to the coin contract
  2. The transfer capability

You can reference (call) functions on the coin contract by simple calling them like normal functions by doing coin.transfer etc.
You can also "import" the whole coin module by doing (use coin) in your contract. This imports all the functions in the coin contract so you can call them like transfer instead of coin.transfer .
But this can cause unexpected bugs if not used with caution, so I recommend always calling them like coin.transfer etc

You need to make sure the "TRANSFER" capability is granted. This can be passed in / specified by the caller when calling the contract.
If your contract is the "owner" of the account (i.e. there's a balance for the contract) you can use the install-capability which will let contract grant itself the capability to do transfers for its account

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文