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:
Token.sol
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
Token.sol
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())));
}
}
Flatten
I used truffle-flattener to create a flattened version of the contract
$ npx truffle-flattener ./contracts/Token.sol > ./contracts/Token_Flat.sol
Verify
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.