Objects & Types

Types of Objects

Type
Description
  • Unsigned integer (whole number)

  • 256 is the default if nothing is specified

    • But it's good to be specific and use uint256

  • Initializes as default 0 if not assigned a value as that is the null value in Solidity

  • Smallest is unit8 as 8 bits is a byte

  • Positive or negative whole number

  • bytes32 is the max size allowed

  • bytes can have "any size"?

    • But I think that will still limit the actual content to 32 bytes

  • Actually a type of bytes in the background, but only used for text

  • boolean

  • true/false

  • An address!

contract SimpleStorage {
    bool hasFavouriteNumber = true;
    uint256 favouriteNumber = 5;
    string favouriteNumberInText = "Five";
    int256 favouriteInt = -5;
    address myAddress = 0x5E666460E5BB4A8Bb14E805478176c36f3b293AB;
    bytes32 favouriteBytes = "cat";
}

Example

Last updated