question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multi file verification on Etherscan

See original GitHub issue

Feature Request

Support multi file verification on Etherscan using Truffle.
This is instead of flattening contracts.

Flattened contracts:

  • Can only contain one SPDX License Identifier (introduced in Solidity 0.6.8) per file. Risking license identifiers being removed, especially from third party libraries.
  • Remove import statements, making it harder to identify how contracts have been imported and from what sources such as an installed npm package
  • Generally harder to ready and identify any inheritance used, including third party libraries such as OpenZeppelin Contracts.

Steps to Reproduce

Verify the following contract inheriting from OpenZeppelin Contracts v3.2.0

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

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

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract SimpleToken is ERC20 {
    /**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */
    constructor() public ERC20("Simple Token", "SIM") {
        _mint(msg.sender, 100000000 * (10**uint256(decimals())));
    }
}

Ideal Behavior

Ideally the contract would be verified as multiple files. The following example shows the six files that make up the contract: https://rinkeby.etherscan.io/address/0x3fFfF0a40E2E3152ab35D78cC49218dD2C35c6cc#code

The contract was verified using https://github.com/nomiclabs/buidler/tree/development/packages/buidler-etherscan which ideally there would be a Truffle plugin that supports multi file verification.

Actual Results

https://github.com/rkalis/truffle-plugin-verify flattens the contracts, removes SPDX License Identifiers and replaces with a single SPDX License Identifier and removes imports so that the contract can compile.

The following example shows a single flattened file for the contract: https://rinkeby.etherscan.io/address/0x5D226974f9ce71179a68B8EDcC7EeE99df8FC3C5#code

Environment

  • Operating System: WSL2 Ubuntu 18.0.4
  • Truffle version:
$ npx truffle version
Truffle v5.1.44 (core: 5.1.44)
Solidity - 0.6.12 (solc-js)
Node v10.21.0
Web3.js v1.2.1

First raised in Truffle: https://github.com/trufflesuite/truffle/issues/3366

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
rkaliscommented, Oct 9, 2020

I tried to do this today, but I ran into some issues in the step “compute the artifact path for this source path”, since it’s pretty difficult to find out the artifact file(s) corresponding to a Solidity file, since a file can include one or more contracts with different names. I think for now I’ll publish the multi file verification with the alphabetical file order soon (rather than the “intuitive” file order) and make an issue of fixing the file order in the future.

1reaction
rkaliscommented, Oct 26, 2020

I just published the new release without the “intuitive” file order. I will close this issue, and create a new one to try to achieve a better ordering.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Etherscan: How can I verify a contract with multiple imports ...
Currently etherscan does not support verification of multifile contracts. But there is discussion on etherscan's reddit about this issue.
Read more >
Easy multifile verification on block explorers - General
Many developers flatten contracts to verify, we need support for easy multifile verification on block explorers.
Read more >
How To Verify a Smart Contract on Etherscan | Chainlink Blog
A step-by-step tutorial showing Web3 developers how to verify their smart contract on Etherscan using multiple different methods.
Read more >
Verifying contracts on Etherscan - Medium
To update token information on Etherscan, the token contract address for the token must be verified. This is to ensure that the contract...
Read more >
How to Verify Smart contract on Etherscan or Polygonscan
How to Verify Smart contract on Etherscan or Polygonscan easilyCode used in ... Support My Channel: Find my NFT Collection on Polygon below....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found