问题
I created a new solidity contract. The contract is up and running but giving me this warning.
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.
There are no errors while compilation.
The Compiler version I am using in https://remix.ethereum.org/ is v0.7.5+commit.eb77ed08 Language: Solidity EVM VERSION: compiler default
Whenever I press compile it gives me the warning but there is no problem while deploying.
My code snippet:
pragma solidity ^0.7.5;
contract TestContract {
// Some logic
}
回答1:
From Solidity ^0.6.8 SPDX license is introduced. So you need to use SPDX-License-Identifier in the code.
Have a look at this: https://forum.openzeppelin.com/t/solidity-0-6-8-introduces-spdx-license-identifiers/2859
For example in your code you need to use license identifier like
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.5;
contract TestContract {
// Some logic
}
You need to use license according to your project. Some other licenses are:
// SPDX-License-Identifier: GPL-3.0-or-later
You can find list of licenses here: https://spdx.org/licenses/
来源:https://stackoverflow.com/questions/65234522/warning-spdx-license-identifier-not-provided-in-source-file