0

I have deployed my smart contract on Base Mainnet, and when i try to verify it on Basescan, I keep getting this error message:

"Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode])
 For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions

Compiler Warning(s):

ParserError: Source "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol" not found: File import callback not supported
 --> myc:4:1:
  |
4 | import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ParserError: Source "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol" not found: File import callback not supported
 --> myc:5:1:
  |
5 | import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol"
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"

I used remix to deploy, and compiled using 0.8.20, with MIT license. Also, I have tried to verify using the "CONTRACT VERIFICATION" plugin on remix, and that's stuck in "pending" despite Base Mainnet not currently undergoing maintenance.

Your help is much appreciated. Thanks

12
  • Try flattening the contract, ie copy and paste everything into a single file. Use the same number of optimisations then try again. | If you have constructor arguments it will likely fail and show both outputs, copy the ending of the one they say they are looking for (from where yours stops to the end) and paste that in the encoded constructor argument section.
    – Maka
    Commented May 12 at 20:16
  • can i flatten the contract by pressing right click on my .sol file and selecting "flatten"? and when you say "try again" do you mean i should compile and deploy the contract again after flattening it? Commented May 12 at 20:31
  • I don't mean deploy again. No idea on a flatten abstraction, try it and see. I mean literally copy and paste all the source into a single file or into the verification window, because the explorers don't handle imports well. Then click verify again, and see if it works or complains that the resulting bytecode is a little different.
    – Maka
    Commented May 12 at 20:35
  • so, doing right click and "flatten" didnt work as it was saying that its looking the SPDX license identifier upon verify. instead i copied and pasted the import contracts from github, and now i get this error: ParserError: Function, variable, struct or modifier declaration expected. --> myc:20:1: | 20 | import {Context} from "../utils/Context.sol" | ^^^^^^ if you can help? Commented May 12 at 20:46
  • ok so i pasted in the contract for context.sol, and now the error i get it this: "ParserError: Function, variable, struct or modifier declaration expected. --> myc:30:1: | 30 | abstract contract Context { | ^^^^^^^^ Commented May 12 at 20:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.