0
0
Blockchain / Solidityprogramming~5 mins

SPDX license and pragma version in Blockchain / Solidity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the SPDX license identifier in a Solidity file?
The SPDX license identifier specifies the license under which the Solidity code is released. It helps tools and users understand the legal terms quickly.
Click to reveal answer
beginner
Where should the SPDX license identifier be placed in a Solidity file?
It should be placed as the very first line in the Solidity file, starting with // SPDX-License-Identifier: followed by the license type.
Click to reveal answer
beginner
What does the pragma version statement do in Solidity?
The pragma version statement tells the compiler which versions of Solidity the code is compatible with, ensuring the code compiles correctly.
Click to reveal answer
intermediate
Explain the difference between pragma solidity ^0.8.0; and pragma solidity 0.8.0;.
pragma solidity ^0.8.0; means the code works with version 0.8.0 and any newer 0.8.x versions but not 0.9.0 or above. pragma solidity 0.8.0; means it only works with exactly version 0.8.0.
Click to reveal answer
intermediate
Why is it important to specify both SPDX license and pragma version in Solidity files?
Specifying SPDX license clarifies legal usage rights, and pragma version ensures the code compiles with the intended compiler version, preventing errors and misunderstandings.
Click to reveal answer
What is the correct way to specify an MIT license in a Solidity file?
A// SPDX-License-Identifier: MIT
B// License: MIT
Cpragma license MIT;
Dlicense MIT;
What does pragma solidity ^0.8.0; mean?
ACompatible with Solidity version 0.8.0 and above, but less than 0.9.0
BCompatible only with Solidity version 0.8.0
CCompatible with any Solidity version
DCompatible with Solidity versions below 0.8.0
Where should the pragma version statement be placed in a Solidity file?
AInside the contract functions
BAnywhere in the contract code
CAt the very end of the file
DAfter the SPDX license identifier and before the contract code
What happens if you omit the SPDX license identifier in your Solidity file?
AThe code will automatically be licensed under MIT
BThe compiler will throw an error and refuse to compile
CThere is no legal information about the code license, which may cause confusion
DThe pragma version will be ignored
Which of the following is a valid SPDX license identifier?
AGPLv3
BGPL-3.0-or-later
CGNU Public License 3
DGPL version 3
Describe the role of the SPDX license identifier and where it should be placed in a Solidity file.
Think about legal clarity and file structure.
You got /3 concepts.
    Explain how the pragma version statement controls which Solidity compiler versions can compile your code.
    Consider compatibility and preventing errors.
    You got /4 concepts.