1

While trying to import

openZeppelin

library in remix IDE (the online version), it always return this error

Contract not found

and this is how I tried to import it

import "github/OpenZeppelin/openzeppelin-contracts/contracts/math/SafeMath. sol";

and it doesn't work and i tried this as well

pragma solidity ^0.4.24;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/math/SafeMath.sol"; 

and it still didn't work as well

How do I import it correctly

gbenga ogunbule
  • 589
  • 1
  • 6
  • 15

1 Answers1

2

It doesn't work because of compiler version.
This will not work:

pragma solidity ^0.4.24;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/math/SafeMath.sol"; 

This will work:

pragma solidity ^0.5.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/math/SafeMath.sol"; 
Peteris
  • 418
  • 2
  • 13
  • Can I port 0.4.24 codes to the 0.5.0? – gbenga ogunbule Sep 23 '21 at 08:19
  • Far as I know then it isn't possible to automatically migrate code and you would need to make changes accordingly to https://docs.soliditylang.org/en/latest/050-breaking-changes.html# I think it is easier to use different SafeMath.sol https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol – Peteris Sep 23 '21 at 09:42