Verify ERC721PresetMinterPauserAutoId deployed contract on rinkeby with Truffle needs help!

:computer: Environment

Truffle

:memo:Details

and successfully minted NFT (using OpenZeppelin Presets in the link above) on rinkeby, thank you so much for the tutorial!

Now, I needed to verify the deployed contracts on rinkeby, but since i was using presets, no code (only json) was provided. I found 2 other threads to help me:

I installed truffle-plugin-verify as outlined in this thread

npx truffle run verify ERC721PresetMinterPauserAutoId --network bsctestnet
Verifying ERC721PresetMinterPauserAutoId
Unexpected token u in JSON at position 0
Failed to verify 1 contract(s): ERC721PresetMinterPauserAutoId

but found out that i could not verify without the solidity source.

i then used the flattener on this thread (since im only npm install --save-dev @openzeppelin/contracts - no v3 as in the thread):

I managed to locate the source from ./node_modules/node_modules/@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol

I ran this command:
npx truffle-flattener ./node_modules/node_modules/@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol > ./contracts/FlatERC721PresetMinterPauserAutoId.sol

and hit this error:
npx: installed 64 in 12.022s
(node:35350) Warning: Accessing non-existent property ‘INVALID_ALT_NUMBER’ of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
(node:35350) Warning: Accessing non-existent property ‘INVALID_ALT_NUMBER’ of module exports inside circular dependency
Error: None of the sub-resolvers resolved “node_modules/node_modules/@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol” location.
at ResolverEngine. (/Users/lucky/.npm/_npx/35350/lib/node_modules/truffle-flattener/node_modules/@resolver-engine/core/build/src/resolverengine.js:35:23)
at Generator.next ()
at fulfilled (/Users/lucky/.npm/_npx/35350/lib/node_modules/truffle-flattener/node_modules/@resolver-engine/core/build/src/resolverengine.js:4:58)

I am pretty much stuck using the programmatic means at this point. My next attempt will be to do this manually on Remix.

I post this here hopefully someone has a solution as truffle so far been very efficient in getting contract tested, and deployed.

Thanks!
:1234: Code to reproduce

See above

Try creating a file contracts/ERC721PresetMinterPauserAutoId.sol with an import:

import '@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol';

Then recompile, and then try to verify using truffle run verify.

1 Like

hi Frangio, thank you so much for the prompt reply.
I tried your suggestion, but still got the same error of unexpected token at position 0 at verify.

~/dev/eth-nft/contracts $ npx truffle compile

Compiling your contracts...
===========================
✔ Fetching solc version list from solc-bin. Attempt #1
> Compiling ./contracts/ERC721PresetMinterPauserAutoId.sol
✔ Fetching solc version list from solc-bin. Attempt #1
> Compilation warnings encountered:

    Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> /Users/lucky/dev/eth-nft/contracts/ERC721PresetMinterPauserAutoId.sol

,Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.8.0;"
--> /Users/lucky/dev/eth-nft/contracts/ERC721PresetMinterPauserAutoId.sol


> Everything is up to date, there is nothing to compile.

~/dev/eth-nft/contracts $ npx truffle run verify ERC721PresetMinterPauserAutoId --network rinkeby
Verifying ERC721PresetMinterPauserAutoId
Unexpected token u in JSON at position 0
Failed to verify 1 contract(s): ERC721PresetMinterPauserAutoId

Thanks again in advance for your help!
L

Hi @frangio

I finally got it working by deploying a new contract with your suggestion. thanks you so much.

here is what i did:
follow the instructions here by @abcoathup

instead of using presets (see Getting the contract artifacts section), don’t copy the build dir, instead use suggestion by @frangio above.

after you have completed all the steps in the tutorial, use this to verify (i used truffle). Another good source if you ran into issue using truffle-plugin-verify is to read the code in the repo (look up rkalis/truffle-plugin-verify in github…sorry, newbie only limited to 2 urls per post).

thx again for @frangio @abcoathup for their help, learn so much from your contribution.

Thanks!
L

2 Likes