所有模块是否会自动继承硬币合同,还是需要进口?
在接受我要赚取的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,唯一的每项条件是
您可以通过执行
Coin.transfer
等来引用硬币合同的转移功能(呼叫)功能。您还可以通过在合同中执行
(使用Coin)
来“导入”整个硬币模块。这会导入硬币合同中的所有功能,因此您可以将它们称为Transfer
而不是Coin.transfer
。但这可能会导致意外的错误,如果不谨慎使用,我建议您始终将它们称为
coin.transfer
等,您需要确保授予“转移”功能。这可以由呼叫者在调用合同时通过 /指定。
如果您的合同是帐户的“所有者”(即合同的余额),则可以使用
internapability
,该将允许合同授予自己的帐户转让的能力So the only per-requisites are
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 liketransfer
instead ofcoin.transfer
.But this can cause unexpected bugs if not used with caution, so I recommend always calling them like
coin.transfer
etcYou 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