File import callback not supported Context.sol

Hi. @abcoathup ,

I’m having the same problem completing the verification and publication of my token.
Unfortunately, I don’t a Windows 10 pc at my disposal. Is there another way to solve this issue?

did you install the OZ npm package?

1 Like

@madeindreams

no, i haven’t. i wasn’t aware of this npm package.
EDIT: i just installed and there’s a warning that it has been deprecated and is no longer supported or maintained.
EDIT2: I also installed Hardhat. I see that the deprecation issue is not unique to OZ.
many thanks @madeindreams.

1 Like

Hi @935782,

Welcome to the community :wave:

Thanks @madeindreams :pray:

Also see the installation instructions: https://docs.openzeppelin.com/contracts/4.x/#overview

I also suggest trying out the Contracts Wizard:
https://docs.openzeppelin.com/contracts/4.x/wizard

Hi @abcoathup,

Thank you very much. It’s great to be welcome.

I will have a look at the links you sent me now.

1 Like

Hi again @abcoathup,

Please help me. I’m trying to figure out why bscscan.com will not verify my code, when the self-same code compiled and deployed flawlessly in Remix. This is the most recent parser error message I’ve received in trying to verify:

ParserError: Source “@openzeppelin/contracts/token/ERC20/ERC20.sol” not found: File import callback not supported
→ myc:8:1:
|
8 | import “@openzeppelin/contracts/token/ERC20/ERC20.sol”

here is my code:

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

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

contract EhmetCoin is ERC20 {
    constructor(uint256 initialSupply) ERC20("EhmetCoin", "EHMET") {
        _mint(msg.sender, initialSupply);
        
           }
        
    }

Please forgive me, but I’m just kind of frustrated by this process because I’m reading about how to use Hardhat and I’m using it while following the instructions in the guides that I’ve found online. I keep running into “You are not inside a Hardhat project” or “You are not inside a Buidler project”. It’s rather amusing that nowhere that I’ve looked is there any documentation on how to actually “be inside a Hardhat project”. Perhaps you can help?

I’ve created ERC20 tokens in the past (Ethereum-based) and they verified with great ease on the very first try, every time. Perhaps, it’s impossible to verify a BEP20 token? Could that be it? Seems odd and strange.

1 Like

Sorry, I am not familiar with the BSC-Chain, maybe you should ask for help in their forum: Home | Binance Chain Forum

And they have a documentation about how to verify contracts, maybe you can have a look at it: Truffle Verify - Binance Chain Docs

You should flatten your contract to verify the code.

I suggest looking at the following Step by Step Tutorials:

1 Like

Hi @Skyge.

Thank you. I’ll have a look at all the options you presented.

I’ve posted on the Binance Chain Forum regarding the verification process. No reply as yet.

Also, the OpenZeppelin step by step Hardhat tutorial is great. It’s definitely better than the others I’ve read. I’m still stuck though. I’ll share with you guys my most recent attempt at verification using Hardhat. Below:

935782@auth MINGW64 ~
$ mkdir my_contract && cd my_contract

935782@auth MINGW64 ~/my_contract
$ npm init -y
Wrote to C:\Users\935782\my_contract\package.json:

{
“name”: “my_contract”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“keywords”: ,
“author”: “”,
“license”: “ISC”
}

935782@auth MINGW64 ~/my_contract
$ npm install --save-dev hardhat
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npx hardhat
888 888 888 888 888
888 888 888 888 888
888 888 888 888 888
8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
888 888 “88b 888P” d88" 888 888 "88b "88b 888
888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888

Welcome to Hardhat v2.0.3

:heavy_check_mark: What do you want to do? · Create an empty hardhat.config.js
Config file created

added 309 packages, and audited 310 packages in 5m

39 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

935782@auth MINGW64 ~/my_contract
$ npx hardhat
Error HH1: You are not inside a Hardhat project.

For more info go to https://hardhat.org/HH1 or run Hardhat with --show-stack-traces

935782@auth MINGW64 ~/my_contract
$ 888 888 888 888 888
bash: 888: command not found

935782@auth MINGW64 ~/my_contract
$ 888 888 888 888 888
bash: 888: command not found

935782@auth MINGW64 ~/my_contract
$ 888 888 888 888 888
bash: 888: command not found

935782@auth MINGW64 ~/my_contract
$ 8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
bash: 8888888888: command not found

935782@auth MINGW64 ~/my_contract
$ 888 888 “88b 888P” d88" 888 888 "88b "88b 888

888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888

Welcome to Hardhat v2.0.3

:heavy_check_mark: What do you want to do? · Create an empty hardhat.config.js
Config file created
npm install --save-dev @openzeppelin/hardhat-upgrades

npm install --save-dev @nomiclabs/hardhat-ethers ethers

npx hardhat verify --network Mainnet 0xa4072b6Bb0664098ef129DA2bD181848862345C8
Nothing to compile
Compiling 1 file with 0.8.0
Successfully submitted source code for contract
contracts/Ehmetcoin.sol:BEP20Token at 0xa4072b6Bb0664098ef129DA2bD181848862345C8
for verification on Etherscan. Waiting for verification result…

New Edit: I attempted to verify the token using the instruction found here:

https://docs.binance.org/smart-chain/developer/deploy/truffle-verify.html

I got the “command not found” error message 17 times when using that. Also, I did edit the truffle code before I used it (mainnet replacing testnet – added the bscscan api key and, of course, the contract address).

1 Like

What would you want to do by this line?

1 Like

Hi @Skyge.

Thanks for your response.
I’m not sure what to do with that line. It’s troubling. I’d like to know how to overcome that or make it not be there. I really need your help with all of this.

I think the common commands are:

npm install --save-dev hardhat             // install hardhat
npx hardhat                                // create your own Hardhat project
npx hardhat compile                        // compile contracts
npx hardhat test                           // run test case
npx hardhat run scripts/sample-script.js.  // deploy contracts

And for more details, I think you can have a look at their documentation: https://hardhat.org/getting-started/

1 Like

Hi @935782,

For instructions on how to setup a node project please see:
https://docs.openzeppelin.com/learn/setting-up-a-node-project

I made a starter kit. Maybe you will have more luck with it?

It’s purely educational.

1 Like

Hi @Skyge @abcoathup @madeindreams.

Wow!

Many thanks to all of you for your kind assistance. At this moment, I’m reading your new messages for the first time and I know that the information that you’ve provided is going to help me. I just have this very strong and positive feeling about what you’ve sent.

Thank you all very much!

Everything you posted is quite useful and enlightening, particularly the information about the .env and the .gitignore files. I was successful in creating those two items. Thanks much for that.

Two things that are hindering my process here: 1) no matter what I’ve attempted to do with Hardhat, I always get the error message: “Error HH1: You are not inside a Hardhat project”. 2) Truffle seemingly is so deprecated that with just about every command I’ve attempted with it, I get the error message saying “Command not found”. Either there are certain things I’m doing terribly wrong or these programs are not functioning as they should. At this point, I’m not sure what the answer is. On another note I opened a support ticket with the bscscan support staff two days ago. No reply from them as yet.

I’m enjoying learning about npm’s and everything else here. Again, to the three of you, many thanks for your kind assistance, your time and your efforts to help me solve this issue.

At the moment, I’m trying Hardhat again…

Same result.

3 Likes

Below are the Solidity, the address, compiler version, the constructor parameters for my token: ehmetcoin:

Remix IDE: Solidity
Contract address: 0xa4072b6Bb0664098ef129DA2bD181848862345C8
Compiler version: 0.8.0
Code:

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

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

contract EhmetCoin is ERC20 {
    constructor(uint256 initialSupply) ERC20("EhmetCoin", "EHMET") {
        _mint(msg.sender, initialSupply);
        
           }
        
    }

The code above compiled and deployed with no errors and no warnings in Remix.

Great, after so many attempts, you finally succeeded.

Hi @935782,

Which network is this? Please include an Etherscan link.
Also what value was used for initialSupply?

Hi @abcoathup.

Binance Smart Network. bscscan.com.

Initial supply is 170000000000.

Thank you @abcoathup.

Hi @Skyge, my apologies that you misunderstood. The compilation and deployment was never the problem. All of that was error-free from the beginning. The problem has been verifying the token on bscscan.com.

Hi @935782,

Verified.

Converted GitHub imports to npm imports. If using GitHub imports you need to use the release tag (not the branch) of an official OpenZeppelin Contracts release, otherwise you are importing the master branch which is subject to change.

EhmetCoin.sol

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

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

contract EhmetCoin is ERC20 {
    constructor(uint256 initialSupply) ERC20("EhmetCoin", "EHMET") {
        _mint(msg.sender, initialSupply);
    }
}

arguments.js

// arguments.js
module.exports = [
    "170000000000000000000000000000"
  ];

verify

$ npx hardhat verify --contract contracts/EhmetCoin.sol:EhmetCoin --const
ructor-args arguments.js --network bsc 0xa4072b6bb0664098ef129da2bd181848862345c8
Nothing to compile
Compiling 1 file with 0.8.3
Successfully submitted source code for contract
contracts/EhmetCoin.sol:EhmetCoin at 0xa4072b6bb0664098ef129da2bd181848862345c8
for verification on Etherscan. Waiting for verification result...

Successfully verified contract EhmetCoin on Etherscan.
https://bscscan.com/address/0xa4072b6bb0664098ef129da2bd181848862345c8#code

@abcoathup.

Thank you so much.
I simply wasn’t able to get there based on my limited knowledge of these things.
You have helped me greatly. Immensely.
Much gratitude to you.

1 Like