Truffle: Truffle: support multi file verification on Etherscan

Created on 16 Sep 2020  路  3Comments  路  Source: trufflesuite/truffle

  • [X] I've asked for help in the Truffle Slack before filing this 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

Most helpful comment

That would be awesome! @abcoathup, would you mind opening this issue on the truffle-plugin-verify repo? Would love to support that in the future!

All 3 comments

Thanks for the feature request! Hey @rkalis, any chance you had any plans to support this kind of thing? This is definitely something that we would like to support in the future. If not in a plugin, then somehow in Truffle itself.

That would be awesome! @abcoathup, would you mind opening this issue on the truffle-plugin-verify repo? Would love to support that in the future!

HI @abcoathup, thanks for bringing this up! We're closing this issue for maintenance, as it sounds like it will be addressed in the truffle-plugin-verify repo.

Was this page helpful?
0 / 5 - 0 ratings