Warm tip: This article is reproduced from serverfault.com, please click

blockchain-警告:源文件中未提供SPDX许可证标识符

(blockchain - Warning: SPDX license identifier not provided in source file)

发布于 2020-12-10 12:27:30

我创建了一个新的团结合同。合同已经启动并开始运行,但是给了我这个警告。

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.

编译时没有错误。

我在https://remix.ethereum.org/中使用的编译器版本v0.7.5 + commit.eb77ed08 语言:Solidity EVM版本:编译器默认值

每当我按compile时,都会发出警告,但部署时没有问题。

我的代码段:

pragma solidity ^0.7.5;
contract TestContract {
// Some logic
}


Questioner
Gogle Gogle
Viewed
88
Gribesh Dhakal 2020-12-10 20:34:00

从Solidity ^ 0.6.8开始,引入了SPDX许可证。因此,你需要在代码中使用SPDX-License-Identifier。

看看这个:https : //forum.openzeppelin.com/t/solidity-0-6-8-introduces-spdx-license-identifiers/2859

例如,在你的代码中,你需要使用许可证标识符,例如

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.5;
contract TestContract {
// Some logic
}

你需要根据项目使用许可证。其他一些许可证是:

// SPDX-License-Identifier: GPL-3.0-or-later

你可以在此处找到许可证列表:https : //spdx.org/licenses/