“错误:事务已恢复:函数选择器无法识别,并且没有后备函数”。 2周都无法解决这个错误

问题描述 投票:0回答:1

我有两个合约 FundMe.sol 和 Price Converter.sol,FundMe 有一个可支付的fund(),并且要求只有用户以太币才应该超过 MINIMUM_USD。因此基金函数接受以太币的价值,并使用 PriceConverter.sol 中的 getConversionRate() 将以太币转换为美元

价格转换器.sol

FundMe.sol

错误

测试脚本

我尝试在 FundMe 合约中创建后备功能来解决错误,但没有成功,现在不知道该怎么办

FundMe.sol 中的后备功能

ethereum blockchain solidity ethers.js hardhat
1个回答
0
投票

尝试在fund()函数中以这种方式调用它:

getConversionRate(msg.value) >= MINIMUM_USD

错误详情:

在你的fund()函数中, 你已经写了,

msg.value.getConversionRate()
。这意味着,它正在尝试调用 msg.value 上的 getConversionRate() 函数。因此,它会错误地恢复
Function Selector was not recognized

如果您有任何疑问,请告诉我。如果有帮助请标记为答案,以便其他人也可以参考。

© www.soinside.com 2019 - 2024. All rights reserved.