WeBASE icon indicating copy to clipboard operation
WeBASE copied to clipboard

library合约中,函数限定符不能为public

Open JacksonRGB opened this issue 3 years ago • 0 comments

pragma solidity 0.6.10;

library SafeSub {
    
    function sub(uint x, uint y) public pure returns(uint) {
        require(x >= y);
        return x - y;
    }
    
}

contract Test {
    function sub(uint x, uint y) public returns(uint) {
        return SafeSub.sub(x, y);
    }
}

调用sub函数时返回错误0x16,因为bincode中存在地址占位符,ide不能自动替换

临时解决:修改SafeSub中sub函数的限定符为internal

JacksonRGB avatar Jun 07 '22 06:06 JacksonRGB