Not able to verify and publish contract on BSC Scan

2.7k Views Asked by At

I'm trying to to verify and publish a contract on BSC Scan testnet. I'm using Open Zepellin and Remix - ETH IDE, however I'm getting the following error:

not found: File import callback not supported

I believe the same issue is true if I try verifying it on Etherscan.

what am I doing wrong?

Contract Link

This is the code I pasted on BSC Scan to verify and publish it.

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

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

contract Presidente is ERC20, Ownable {
    constructor() ERC20("Presidente", "PRES") {
        _mint(msg.sender, 1000000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

this is the full error I get enter image description here

1

There are 1 best solutions below

0
On

i see that you are trying to verify while the contract you have needs to be flattened,

here is what you need to do:

  1. Go to remix.ethereum.org and create a new file token.sol

  2. copy/paste your code in it and save it

  3. go to the last tab plugin manager and look for FLATTENER install it

  4. FLATTENER will show as a tab click on it and press on Flatten token.sol

  5. press on Save as token_flat.sol

  6. go back to the first tab and you'll find the new file

  7. remove all of the extra license showen "// SPDX-License-Identifier: MIT"

  8. move the second part to become the theird part

    pragma solidity ^0.8.0;

    /**

    • @dev Interface for the optional metadata functions from the ERC20 standard.

    • Available since v4.1. / interface IERC20Metadata is IERC20 { /*

      • @dev Returns the name of the token. */ function name() external view returns (string memory);

      /**

      • @dev Returns the symbol of the token. */ function symbol() external view returns (string memory);

      /**

      • @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }

    // File: @openzeppelin/contracts/token/ERC20/IERC20.sol

after this part

    pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
  1. compile and you will be good to go