Asked in a Discord channel:
How to verify a contract deployed using Remix importing OpenZeppelin via GitHub?
Example:
Asked in a Discord channel:
How to verify a contract deployed using Remix importing OpenZeppelin via GitHub?
Example:
I have compiled and deployed the contract on remix with the flattener plug-in enabled,
Then I have flattened the code for verification on etherscan which gives us these errors
As suggested by you to flatten the contract when you have imports (even importa from GitHub of zeplin). Then we did that but seems etherscan doesn’t know which contract bytes to compare to when you have a single file and many contracts defined in it…
So you can reproduce this if you make a simple token erc721 or erc20 and import all it’s dependencies from GitHub deploy on remix then flatten it and try to verify it…
Thanks
Hi @x5engine,
Welcome to the community
Thanks for posting in the forum
The following is an example of verifying a contract deployed using Remix importing OpenZeppelin via GitHub.
Any solution should be appropriately tested and audited.
When OpenZeppelin CLI supports verifying regular (non-upgradeable) contracts, it will be easier to deploy, interact, test and verify from the CLI. (OpenZeppelin CLI 2.8 Release Candidate supports deploy, interact and using OpenZeppelin Test Environment - testing, but doesn’t yet verify regular contracts).
I deployed the following example contract using Remix:
pragma solidity ^0.5.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Detailed.sol";
contract Token is ERC20, ERC20Detailed {
constructor () public ERC20Detailed("Token", "TKN", 18) {
_mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
}
}
I tried using the Flattener plugin for Remix but this failed to verify on Etherscan.
Instead I created a new project locally and installed OpenZeppelin Contracts and Truffle (as truffle-flattener needs Truffle) to flatten locally.
npm i @openzeppelin/contracts
npm i truffle
I converted the imports to use the installed OpenZeppelin Contracts (the version needs to match what is used by the version imported by Remix.
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
contract Token is ERC20, ERC20Detailed {
constructor () public ERC20Detailed("Token", "TKN", 18) {
_mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
}
}
I used truffle-flattener to create a flattened version of the contract
$ npx truffle-flattener ./contracts/Token.sol > ./contracts/Token_Flat.sol
I verified the contract on Etherscan as a single flat file, with compiler 0.5.16 and no optimization and it verified successfully.
Note: I didn’t have any constructor parameters in this example.
Hi @x5engine,
Were you able to verify your contract?
A post was split to a new topic: Verify ERC20 token on Etherscan
A post was split to a new topic: Use Truffle Flattener on Windows
@abcoathup Thanks … your posts always show up first when I google a question !
It would be great if Remix could do the import “as is”, then I could work from the same code base, and also (see above) could avoid “version needs to match what is used by the version imported by Remix.”
… or is there already something to support either of these two “nice to have features” ?
Hi @sven.meyer,
Verification is a pain point. I want to find out from the Remix team what is possible.
As for finding my posts using web search, that is great. Except when I am looking for an answer and all I can find are my own posts.
Hi why it’s show currently you have no contract instances to interact with
I ran into some errors using truffle-flattener. This “flatten-sol” CLI should work ngduc/flatten-sol
Hi, I was not aware off contract verification requires by the BSCScan, I've then deployed after compiled. Then once I found the necessity of being a verified contract on BSCScan, I had returned to copy the source code on the remix opened direct from OpenZepplin. I copy the short soft codes but BSCSCan didn't found any match to verify my contract. How can copy my Contract source code after I'd deployed my token contract?
Hi, welcome!
maybe you can have a look at this tutorial: Verify erc20 token on etherscan that was deployed through remix:step by step guide
And for the next time, please search at the forum at first, and then ask questions, thanks!
How do I ask a good question? - General / Meta - OpenZeppelin Community