Ethereum 调用super.owner().transfer(msg.value)时出现错误
我有一份合同继承了开放式齐柏林飞艇的合同。在我的合同中有一种方法payFees(),它可以将资金转移给合同的所有者。付费的定义如下Ethereum 调用super.owner().transfer(msg.value)时出现错误,ethereum,solidity,openzeppelin,Ethereum,Solidity,Openzeppelin,我有一份合同继承了开放式齐柏林飞艇的合同。在我的合同中有一种方法payFees(),它可以将资金转移给合同的所有者。付费的定义如下 function payFees() public payable { require(students.has(msg.sender), "DOES NOT HAVE STUDENT ROLE"); if(this.areFeesEnough(msg.value)) { super.owner
function payFees() public payable {
require(students.has(msg.sender), "DOES NOT HAVE STUDENT ROLE");
if(this.areFeesEnough(msg.value))
{
super.owner().transfer(msg.value);
studentFees[msg.sender] = true;
}
}
我希望调用super.owner()返回合同所有者,因为owner()
是返回所有者的父Ownable
合同中的公共视图函数。不幸的是,代码失败并出现错误
TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address.
super.owner().transfer(msg.value);
感谢您的帮助。假设您使用的
可拥有的
合同与类似,问题是所有者()
返回一个地址
,但从0.5开始,您只能将以太转移到应付地址
您可以先通过uint160
进行转换,如下所示:
address(uint160(_owner)).transfer(msg.value);
请注意,您可以直接使用\u owner
,也可以调用owner()
。无需调用super.owner()
,除非您在合同中覆盖了owner
,并且需要确保调用父合同