9

合约函数定义了类型但是没参数名称,这样的函数用什么用?

 2 years ago
source link: https://learnblockchain.cn/question/2606
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

合约函数定义了类型但是没参数名称,这样的函数用什么用?

function execute(
	address, /* user */
        address borrowToken,
        uint256, /* borrow */
        uint256, /* debt */
        bytes calldata data
    ) external  {
        
    }

类似这个函数,定义了5个参数类型,但是有3个都没名字,也用不了啊,那么这几个参数有啥意义呢?

最佳答案 3天前

这种情况通常为了保持接口的一致性。

例如下图:

X 合约会调用 A B C 合约的 execute 方法,你看到的 A 合约里,可能只需要使用到 execute 的 borrowTokendata 参数,但是 B 和 C 合约可能需要其他的参数,因此 A 保持接口一致,才能被 X 以统一的接口调用。

Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 39% | 回答于 3天前

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK