[Ethereum] Is library use inherited

inheritancelibrary

When a base class uses a library, do derived classes also use the same library?

For example:

contract A {
    using SafeMath for uint256;
    ...
}
contract B is A {
    //is code here using SafeMath for uint256? 
}

Best Answer

No.

In Solidity 0.7.0 and later versions, the effect of using ... for is no longer inherited.

Quoting from the 0.7.0 changelog:

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.

Related Topic