Elements

Introduction

To add elements to the metamodel design, click the "+" button next to functions. Give each element a specific and descriptive name to clearly indicate its functionality and differentiate it from other elements. A well-chosen name helps to infer the element's purpose and ensures clarity in your design.

Configuration

Condition

The Condition Element is used to create a condition in the flow of a Solidity smart contract.

  • Type: Determines the behavior of the condition:

    • If: A traditional condition that splits the flow into two subflows based on whether the condition is met.

    • Assert: Tests for internal errors and checks invariants. It does not throw an error message and should be used like an exception.

    • Require: Checks for validity before execution, typically for input validity, and can throw an error message if the condition is not met.

    Define the condition via a dedicated Operation.Specify which element the flow should split to if the condition is not met; if the condition is met, the flow will continue to the next element.

Contract Instantiation

The Contract Instantiation Element is used to create a new Contract instance from the current contract.

  1. Select Contract: Choose the contract you wish to instantiate.

  2. Map Inputs: If the selected contract has a constructor with inputs. Map the currently available Data Entities to these inputs to ensure correct instantiation.

  3. Encapsulate Contract: Encapsulate the instantiated contract in a contract-type variable. This variable can be used to reference the instantiated contract in other parts of the flow.

This process allows you to seamlessly create and manage new contract instances within your smart contract flow.

Data Entity Instantiation

The Data Entity Instantiation Element is used to create and define new data entities within your smart contract. This process generally involves both defining and instantiating a new data entity. However, for complex data structures like structs, you can refer to an already defined struct and instantiate it using this element.

  1. Define or Select Data Entity: Choose the specific Data Entity you wish to instantiate. This could be a new simple type (like an integer, boolean, or string) or a complex type (like a struct).

  2. Instantiate Structs: If you are working with structs, select an already defined struct and instantiate it. This allows you to create instances of the struct with specific properties.

  3. Create and Define Operation: Once the Data Entity is instantiated, define an operation to perform on it. This operation can be used to immediately assign a value to the data entity, ensuring it is initialized with the required data.

By using the Data Entity Instantiation Element, you can efficiently manage the creation and initialization of various data entities, making your smart contract more organized and functional.

Data Entity Manipulation

The Data Entity Manipulation Element is used to alter the value of an existing Data Entity within your smart contract.

  1. Define or Select Data Entity: Choose the Data Entity you want to manipulate. This could be any previously defined data entity within your contract.

  2. Define the Manipulation: Specify the type of manipulation through a dedicated operation. This could involve operations like updating the value, performing arithmetic calculations, or modifying specific properties of a complex data type such as a struct.

By utilizing the Data Entity Manipulation Element, you can dynamically alter data within your smart contract, ensuring it behaves as required under different conditions.

Event Emission

The Event Emission Element is used to emit a predefined event, which can be either user-created or imported from another source.

  1. Select Event: Choose the specific event you want to emit. This can be a custom event you have created or an event imported from another contract.

  2. Map Event Input: Map the existing Data Entities to the required inputs of the event. This ensures that the event is emitted with the correct data values.

By using the Event Emission Element, you can trigger events within your smart contract, allowing you to signal specific actions or changes to the external environment or other parts of your application.

Function Call

The Function Call Element is used to call an existing function within the current flow. This can be either a custom function or a function imported from another source.

  1. Select Function: Choose the function you want to call.

  2. Input Mapping: If the function requires input, ensure compatible data entities are present in the flow. Map these inputs to the corresponding data entities.

  3. Return Mapping: Map the function's return value to a compatible data entity.

  4. Contract Address: If the function you are calling is from an already deployed contract, specify the contract's address.

This setup allows you to seamlessly integrate and utilize existing functions within your smart contract flow.

Loop

The Loop Element is used to create a sequence of instructions that repeats until a specified condition is met.

  1. Create Condition: Define the condition that will determine when the loop ends. The loop will continue until this condition is met.

  2. Select Function: Choose a function to execute as the loop's logic. This function will be repeatedly executed until the loop's condition is satisfied.

This setup allows for repetitive execution of instructions within your smart contract flow, providing flexibility and control over the contract's behavior.

Loop Iterator

The ElementLoopIterator Component is used to define an iterator for loops within smart contracts. It links a simple data entity as the iterator and includes an assignment operation for initialization. Additionally, it allows you to specify the iteration step for 'for' loops.

  1. Define Iterator: Select a simple data entity to serve as the iterator for the loop.

  2. Initialize Iterator: Use an assignment operation to set the initial value of the iterator.

  3. Specify Iteration Step: Define the step value for 'for' loops, which determines how the iterator value changes with each loop iteration.

By using the ElementLoopIterator Component, you can effectively manage loop iterations within your smart contract, ensuring precise control over the loop execution.

Transfer

The ElementTransfer Component facilitates Ether transfers within Solidity smart contracts by defining key attributes and integrating with various data entities to manage and track transaction outcomes effectively.

  1. Receiver: Specify the recipient's address for the Ether transfer.

  2. Amount: Define the amount of Ether to be transferred.

  3. Success Status: Track the success status of the transfer to ensure it has been completed successfully.

  4. Optional Return Data: Handle any optional return data that may be associated with the transfer.

By using the ElementTransfer Component, you can seamlessly manage Ether transactions within your smart contract, ensuring all necessary details are tracked and recorded.

Return

The Return Element is used to specify a Data Entity to be returned by the function. This means that whenever the function is called, it will return the specified Data Entity as the result of its execution.

  1. Define or Select Data Entity: Choose the Data Entity that will be returned by this function.

By using the Return Element, you can ensure that your function outputs the desired Data Entity, providing a clear result for its execution.

Last updated