You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenZeppelin onlyOwner修饰符异常:getICOMembers函数Etherscan调用失败

合约调用异常问题

在Remix环境中,getICOMembers函数可正常工作,能返回添加到icoMembers映射后的指定ICO类型的所有成员:

映射定义

mapping(uint256 => address[]) private icoMembers;

getICOMembers函数

function getICOMembers(uint256 _icoType) external view onlyOwner returns (address[] memory) 
{
    return icoMembers[_icoType];
}

但使用Owner地址在Etherscan上调用该函数时,始终返回错误。而同样带有onlyOwner修饰符的getICODatas函数却能正常工作:

ICOdatas数组定义

ICOdata[] private ICOdatas;

getICODatas函数

function getICODatas() external view onlyOwner returns (ICOdata[] memory) 
{
    return ICOdatas; 
}

已尝试以下操作但问题未解决:

  • 硬编码添加成员(不通过代币销售加入函数)
  • 将函数的external修饰符改为public

以下是合约的构造函数代码:

constructor(
    address _token,
    address payable _usdtWallet,
    address _vestingContract
) {
    require(
        address(_token) != address(0),
        "ERROR at Crowdsale constructor: Token contract address shouldn't be zero address."
    );
    require(
        _usdtWallet != address(0),
        "ERROR at Crowdsale constructor: USDT wallet address shouldn't be zero address."
    );
    require(
        _vestingContract != address(0),
        "ERROR at Crowdsale constructor: Vesting contract address shouldn't be zero address."
    );

    token = ERC20(_token);
    usdtWallet = _usdtWallet;
    totalAllocation = 0;
    vestingContract = IVesting(_vestingContract);
    transferOwnership(msg.sender);
}

内容的提问来源于stack exchange,提问作者samet mollaoglu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 17:55:42