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.

Fix "ParserError: Multiple SPDX license identifiers found in source file"

See original GitHub issue

When you have two contracts, one depending form another, since solc v0.6.8, all of them should contain the SPDX license.

When I try truffle run verify it would yield the error

General exception occured when attempting to insert record 
Failed to verify 1 contract(s): <name of your contact>

If I do manually npx truffle-flattener and upload it for etherscan I get the more detailed error:

Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode])
...
myc: ParserError: Multiple SPDX license identifiers found in source file. Use "AND" or "OR" to combine multiple licenses. Please see https://spdx.org for more information.
  • when I remove the duplicates of // SPDX-License-Identifier from contact before upload to etherscan this error disappears. So I assume that corresponding fix is needed.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rkaliscommented, Feb 16, 2021

Hmm interesting, thanks for looking into it @Enigmatic331!

I’m guessing that the “double escape” is due to an error on my side when trying to output the Input JSON manually, since for API usage, the JSON content does gets stringified (as expected).

So then manual verification for this contract did work, but the API returns “General exception occured when attempting to insert record”. Do you have any indication for what this API response means on the Etherscan side?

1reaction
Enigmatic331commented, Feb 15, 2021

Hey Rosco! Thanks for pinging.

Hmm. I popped open one of the files and had a quick look. Seems like they’re JSON escaped twice? I unescaped them once and cleaned the formatting it a little (just so it’s easier on my eyes), then reattempted verification through Etherscan: https://rinkeby.etherscan.io/address/0x71694eE1B3D95885FF94202f631B942462fD6B08#code

The file I used as attached (rename the file as .json): 2.txt

The “double escape” is causing issues with solc compilation when I tried directly with solc.exe (hint: if Etherscan shows no compiled bytecode during verification, it means solc could not compile it at all) - So removing one layer of escape should be all it was needed.

@lebed2045 - I see you Alex of StableUnit 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error! Multiple SPDX license identifiers found #37 - GitHub
Found it! A way to fix this issue is to remove one SPDX comment from the merged file so it doesn't throw an...
Read more >
Multiple SPDX license identifiers found in source file. Use ...
ParserError : Multiple SPDX license identifiers found in source file. Use “AND” or “OR” to combine multiple licenses — And How To Fix...
Read more >
Solidity 0.6.8 introduces SPDX license identifiers - General
we introduced a recommendation to use SPDX license identifiers for all source files which are also stored in the contract metadata.
Read more >
SPDX license when importing other people's contracts
An alternative (but worse) solution is to use a flattening tool that can remove SPDX Identifiers, such as sol-merger. Then you can add...
Read more >
Warning: SPDX license identifier not provided in source file
I created a new solidity contract. The contract is up and running but giving me this warning. Warning: SPDX license identifier not provided...
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