- Replacing memory with calldata when stack is enough
- Definitions
- Visibility
- State mutability
- Modifiers
- Virtual
- Override
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract HelloWorld {
string private text;
constructor() {
text = "Hello World";
}
function helloWorld() public view returns (string memory) {
return text;
}
function setText(string calldata newText) public {
text = newText;
}
}
- Elementary types
- Booleans
- Integers
- Fixed
- Address
- Bytes
- Strings
- State Variables
- Constants
- Data locations (again)
- Arrays
- Mappings
https://docs.soliditylang.org/en/latest/types.html
- Extending new features
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract HelloWorld {
string private text;
constructor() {
text = pureText();
}
function helloWorld() public view returns (string memory) {
return text;
}
function setText(string calldata newText) public {
text = newText;
}
function pureText() public pure returns (string memory) {
return "Hello World";
}
function _isPure() internal view returns (bool _check) {
_check = keccak256(bytes(text)) == keccak256(bytes(pureText()));
}
function isPure() public view returns (bool _returnValue) {
_returnValue = _isPure();
}
function _restore() internal {
text = pureText();
}
function restore() public returns (bool) {
if (_isPure()) return false;
_restore();
return true;
}
}
- Reserved words and global variables that a programmer should know
- Global variables about blockchain state
- Global variables about the transaction
- Global variables about the transaction message
https://docs.soliditylang.org/en/latest/units-and-global-variables.html
- How errors are handled on solidity (briefly)
- Assertion
- Require statements
- Modifiers
- Where to use modifiers
https://docs.soliditylang.org/en/latest/structure-of-a-contract.html#function-modifiers
- Create Github Issues with your questions about this lesson
- Read the references