Value types in Solidity
Sized integers, address, bool, bytes32: the primitives.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
// Sized integers, address, bool, bytes32: the value types.
contract PlotRecord {
uint256 public trees = 48;
int16 public frostMarginC = -3;
address public keeper = address(0);
bool public irrigated = true;
bytes32 public plotId = keccak256("north-slope");
function double() external view returns (uint256) {
return trees * 2;
}
}
How it works
uint256andint16size their storage exactly.address(0)is the zero address, the conventional empty.keccak256("...")fills abytes32fingerprint.
Keywords and builtins used here
addressboolbytes32contractexternalfunctionint16keccak256publicreturnreturnstrueuint256
The run, in numbers
- Lines
- 15
- Characters to type
- 389
- Tokens
- 64
- Three-star pace
- 60 tpm
At the three-star pace of 60 tokens a minute, this run takes about 64 seconds.
Step 2 of 4 in Contracts, step 2 of 28 in Language basics.