如何仅通过钱包地址来创建坚固的功能(不是合同)

发布于 2025-02-13 13:29:55 字数 94 浏览 1 评论 0原文

我想确保无法通过另一份智能合约以编程方式调用我的功能。

是否有一种方法可以在我的合同中创建一个函数,而这些函数不允许其他合同调用,同时仍允许普通钱包调用该功能?

I want to make sure that my function isn't able to be called programmatically by another smart contract.

Is there a way to create a function in my contract that doesn't allow it to be called by other contracts while still allowing ordinary wallets to call the function?

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

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

发布评论

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

评论(1

好久不见√ 2025-02-20 13:29:55

因此,msg.sender返回称为您方法的地址,tx.origin返回发送交易的帐户的地址。

/// @dev Check if method was called by user.
require(msg.sender == tx.origin, "Reverting, Method can only be called directly by user.");

So, msg.sender returns the address who called your method, and tx.origin returns the address of the account that sent the transaction.

/// @dev Check if method was called by user.
require(msg.sender == tx.origin, "Reverting, Method can only be called directly by user.");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文