Hello, I developed a simple ERC721 contrat throught OpenZeppelin on the new Coinbase L2, the Base chain but when I try to verify my contract I see this " Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode])"
I made some researches here and found some solutions for BNB chain and Ethereum but I am a newbie and I have no idea on how to proceed. Also I have a chromebook laptop, could it be a problem? Thanks in advance and kind regards!
Please share details (how, where, etc).
thanks for your answer (and your time)! I developed it almost 48h ago and tried to verify some minutes ago.
This is the contract and basescan seems not recognizing the "@openzeppelin" wording
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts@4.9.3/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.9.3/access/Ownable.sol";
contract BasedBases is ERC721, Ownable {
constructor() ERC721("BasedBases", "BDBS") {}
function safeMint(address to, uint256 tokenId) public onlyOwner {
_safeMint(to, tokenId);
}
}
You need to flatten the contract's code.
You can do this manually, by replacing every import
statement with the actual code being imported.
Or there is possibly a 'flatten source code' button somewhere in there (again - you haven't mentioned what platform you're using in order to verify your contract - etherscan, remix, etc - so it's a bit hard to say for sure).
Alright, thank you, I flattened it throught remix.. should I deploy it again?
No, flattening the code doesn't change anything in the actual bytecode.
The sole purpose of this flattening is in order to able to verify the contract.
Thank you barakman! I tried verifying it buuuut still go an error:
Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code : Address , BasedBases , Context , ERC165 , ERC721 , IERC165 , IERC721 , IERC721Metadata , IERC721Receiver , Math , Ownable , SignedMath , Strings
But we were unable to locate a matching bytecode (err_code_2)
UPDATE: just found the (viral) error: the license
I followed a tutorial where the guy advised to select "no license" but I remember I always selected "MIT license" when I created any contract.
You need to do this recursively of course (i.e., keep replacing every import
statement until there are none left).
Alright, will do it! Thanks for your precious help!
1 Like