2

I've seen multiple times Solidity contracts, which are using import "@somename/.../SomeContract.sol" syntax. Here's the example:

pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";


contract TestContract is IERC20 {
    uint asdasd;
}

How can I use this syntax with Remix? When I'm trying to use Remix (solc 0.5.17), I'm getting the following error:

enter image description here

1

Of course it fails since you don't have the Openzeppelin contracts in Remix. This has nothing to do with the "@" syntax. The "@" just indicates the owner of a specific npm package.

In Remix you can either

  1. Import the file directly via Github.
  2. Download the file and manually insert it.

Automatic import via Github would work like this

pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol";

contract TestContract is IERC20 {
    uint asdasd;
    
    // implement ERC20 functions here
}
| improve this answer | |
  • Thanks a lot for your answer and hope this question will help newbies - lot of tutorials use this syntax and recommend using Remix simultaneously. – Sergey Potekhin Aug 12 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.