0

I have a contract using Open-Zeppelin SafeMath, but that declaration is not recognized by derived contracts.

Base.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";

contract Base  {
    using SafeMath for uint256;
}

Test.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "Base.sol";

contract Test is Base {
    function getnum(uint256 _number) external view returns (uint256) {
        return _number.add(_number);
    }
}

But I keep getting this error:

Member "add" not found or not visible after argument-dependent lookup in uint256.
drab
  • 426
  • 3
  • 15

1 Answers1

0

using A for B statemen has changed in solidity 0.7, now we have to repeat the statement in all derived contracts:

using A for B only affects the contract it is mentioned in. Previously, the effect was inherited. Now, you have to repeat the using statement in all derived contracts that make use of the feature.

https://solidity.readthedocs.io/en/v0.7.4/070-breaking-changes.html#functions-and-events

drab
  • 426
  • 3
  • 15