This has been a problem I've been dealing with for a while now. My temporary solution has been to create a SafeMath.sol file in my Contracts directory and directly import it from there. However, I've been looking for a 'clearer solution' to this... Old way seemed to be directly importing it from a GitHub link, as seen in some repos and other stack overflow posts like such
However, the proper way do this seems to be installing the corresponding oz package (@openzeppelin/contracts-ethereum-package) and importing the file directly into the needed contract i.e.
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
However, using VSCode, I still get the error Source "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol" not found: File import callback not supported
That said, how can I properly import SafeMath?
EDIT: I am using pragma solidity ^0.6.0;
@openzeppelin/contracts
by npm and import the lib to my contract byimport "@openzeppelin/contracts/math/SafeMath.sol";
– Rubennode_modules
are recognized by VSCode and debug that issue first. – Wallraff