Data Entities

Introduction

Data Entities are variables, either simple or complex, used within a Contract and its Functions. When defined in the left sidebar, these data entities are global, meaning they can be accessed and modified by any function within the contract.

Configuration

Give your data entity a specific and descriptive name to clearly indicate its purpose and distinguish it from others. The name will be used as a keyword in the code, so choose something that makes the data entity's function easy to infer.

Select a Data Entity Type among all available types in Solidity. This selection will specialize the data entity so to access the dedicated properties. Then you can define the storage location of a Data Entity. This will affect how (and whether) the Data Entity is stored in the contract's storage.

Type Settings

  • A Simple Data Entity is a data type used to hold basic values such as numbers, booleans, and strings.

    • State: Defines whether the data entity's value can be modified after assignment.

      • Constant: Cannot be changed after compilation.

      • Immutable: Can be set within a constructor but not modified afterwards.

    • Subtype: Specifies the type of data the entity is storing.

  • Array: The Array Type specifies the kind of Data Entities stored in the array. An array can hold only a single type of data entity, ensuring consistency in the data it contains.

  • Struct: A Struct Data Entity is a data structure that combines different data types. The struct's name identifies the subsets of variables it contains. Once defined and instantiated, any of the struct's data types can be assigned a value or accessed.

  1. Select an existing Struct (this is used when you want to instance a Struct following an already defined one).

  2. Create a new Property (this is used to define Structs)

  • Array of Structs: Select an already defined Struct Data Entity for this Array.

  • Enum: An Enum values define a set of predefined constants that can be used for several purposes, such as checking whether a variable name is among them.

  • Mapping: A Data Entity Mapping is use to create a Solidity mapping. In Solidity, mappings function similarly to a dictionary or hash table in another language. These are used to store data in the form of key-value pairs, with the value being able to be of any type and the key being any of the built-in data types, but reference types (i.e. Structs, Arrays) are not permitted to be used as keys.

  1. Define the Type for the Mapping's Key

  2. Define the Type for the Mapping's Value

  3. Select an existing Mapping (this is used when you want to instance a Mapping following an already defined one)

  • Mapping of Structs: A Mapping of Structs is use to create a Solidity mapping where the mapping's values are structs. In Solidity, mappings function similarly to a dictionary or hash table in another language. These are used to store data in the form of key-value pairs, with the value being able to be of any type and the key being any of the built-in data types, but reference types (i.e. structs, arrays) are not permitted to be used as keys.

  1. Define the Mapping's Key type

  2. Define the Struct used as Mapping Value

  3. Select an existing Mapping of Structs (this is used when you want to instance a Mapping following an already defined one)

  • Free Input: A Free Input Data Entity is used to create a Data Entity with a custom value.

  1. The Type determines the type of data for this Free Input Data Entity. Naturally, this will also affect the kind of custom value that can be assigned to the data entity.

  2. This field defines the custom value that is assigned to this Free Input Data Entity.

  • Pointer: Data Entity Pointer is used to point to structure's property or to a mapping property.

  • DataEntitySpecial: DataEntitySpecial Component: Defines special data entities like msg.sender, msg.data, and msg.value for use in smart contracts, providing attributes for customization and linkage to other contract components.

Last updated