Truffle-flattener: ParserError: missing ';' at '{'

Hi there,

Im trying to verify a ERC721 contract (created based on open zeppelin contracts) using truffle-flattener but I got this error:

Error: Could not parse C:\Users\xxx\Desktop\Tests\PACKAGE\ethereum_dev\arup_iia\contract_deployment\node_modules\@openzeppelin\contracts\utils\Counters.sol for extracting its imports: ParserError: missing ';' at '{' (26:18)
at getDependencies (C:\Users\xxxx\Desktop\Tests\PACKAGE\ethereum_dev\contract_deployment\node_modules\truffle-flattener\index.js:44:11)
at dependenciesDfs (C:\Users\xxx\Desktop\Tests\PACKAGE\ethereum_dev\contract_deployment\node_modules\truffle-flattener\index.js:64:24)

And this is the smart contract:

// contracts/Nft.sol

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.3;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

import "@openzeppelin/contracts/utils/Counters.sol";

contract Nft is ERC721URIStorage {

    using Counters for Counters.Counter;

    Counters.Counter private _tokenIds;

    address payable public owner;

    constructor() ERC721("NonFungibleFaces", "NFF") {

        owner = payable(msg.sender);


    function awardItem(address player, string memory tokenURI)

        public payable

        returns (uint256)


        require(msg.value >= 5); //5 wei is the fee to run it


        uint256 newItemId = _tokenIds.current();

        _mint(player, newItemId);

        _setTokenURI(newItemId, tokenURI);

        return newItemId;


    function tokenId() public view returns (uint256) {

        return _tokenIds.current();


    function balance() public view returns (uint256) {

        return (address(this).balance);


    function withdraw() public {

        require(msg.sender == owner);




Any hints? The contract has been deployed with no errors to the testnet…


1 Like

Hi @ismahelio,

I am not sure why you are getting this error.

I recommend verifying using Hardhat (or Truffle if you deployed with Truffle) rather than flattening: Verify smart contract inheriting from OpenZeppelin Contracts

1 Like

I will try this today. Thanks!

In relation with the previous question. Since the contract is mine and I know the functions inside it.

Is there a way to access the functions from the contract without the ABI? or another way to get the ABI from the contract? I usually just verify the contract, copy the ABI from etherscan and then use something like this:

const smartContract = new web3.eth.Contract(abiToken, smartContractAddress)

1 Like

I tried:

npx truffle run verify Nft --network rinkeby

And I got this error:
Invalid constructor arguments provided. Please verify that they are in ABI-encoded format

I have tried to follow other posts to fix this error within truffle but I can’t find a way.

1 Like

Hi @ismahelio,

Do you want to share your contract address on Rinkeby?



1 Like

Hi @ismahelio,

Did you have optimization enabled? I wasn’t able to verify, so it looks like the code is different from what was actually deployed.

$ npx hardhat verify --network rinkeby 0xD3058F17b44b8DfCEC6342794c4A4FB2e831a37d
Compiling 13 files with 0.8.3
Compilation finished successfully
Error in plugin @nomiclabs/hardhat-etherscan: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts.

Possible causes are:
  - Contract code changed after the deployment was executed. This includes code for seemingly unrelated contracts.
  - A solidity file was added, moved, deleted or renamed after the deployment was executed. This includes files for seemingly unrelated contracts.
  - Solidity compiler settings were modified after the deployment was executed (like the optimizer, target EVM, etc.).
  - The given address is wrong.
  - The selected network (rinkeby) is wrong.

For more info run Hardhat with --show-stack-traces

I was able to deploy your contract and verify it, so assume you deployed with optimization or a change to the code.

$ npx hardhat run --network rinkeby scripts/deploy.js
Compiling 13 files with 0.8.3
Compilation finished successfully
Deploying Token...
Nft deployed to: 0x0bCDFc74900D50ab96FaD6a059447c7189E23B7d

$ npx hardhat verify --network rinkeby 0x0bCDFc74900D50ab96FaD6a059447c7189E23B7d
Nothing to compile
Compiling 1 file with 0.8.3
Successfully submitted source code for contract
contracts/Nft.sol:Nft at 0x0bCDFc74900D50ab96FaD6a059447c7189E23B7d
for verification on Etherscan. Waiting for verification result...

Successfully verified contract Nft on Etherscan.
1 Like

I have seen that you have changed the documentation on how to deploy smart contracts and now by default is hardhat and not truffle anymore.

After going through the process again from the beginning it’s all working good. Thanks Andrew!


I faced on with the same issue. Do I need to use hardhat?
It's can't be fixed with truffle?

Okay so I moved everything from truffle to hardhat. It works

truffle-flattener has had an old dependency for solidity-parser, this is fixed in 1.6.0: