gpt4 book ai didi

ethereum - 警告 : Using contract member "balance" inherited from the address type is deprecated. 坚固性

转载 作者:行者123 更新时间:2023-12-02 21:37:15 28 4
gpt4 key购买 nike

Warning: Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).balance" instead.

我使用 Remix 编辑器在 Solidity 中收到此警告。

这是代码块:

function getSummary() public view returns(
uint, uint, uint, uint, address
){
return (
minimumContribution,
this.balance, // This is the warning line.
requests.length,
approversCount,
manager
);
}

我尝试按照警告的建议进行操作:

function getSummary() public view returns(
uint, uint, uint, uint, address
){
return (
minimumContribution,
address(contract).balance,
requests.length,
approversCount,
manager
);
}

但这不起作用。

最佳答案

balanceaddress 类型的属性,而不是来自合约。将其更改为address(this).balance

function getSummary() public view returns(
uint, uint, uint, uint, address
){
return (
minimumContribution,
address(this).balance,
requests.length,
approversCount,
manager
);
}

关于ethereum - 警告 : Using contract member "balance" inherited from the address type is deprecated. 坚固性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51372365/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com