Chapter 2: Intermediate

Lesson 3: Builtin operators

Now, we will run an operation to see whether sender and owner variable are the same and will store the value in a temporary variable which we had earlier learned about in the first chapter.

In order to check whether two variable values are equal to each other, we use eq.

This expression checks whether variable i1 is equal to i2 It returns a boolean value True or False which can be stored in a variable.

We can use the expression in a transition and store the result in a variable. We will learn how to check the result in the next lesson.

We have a task for you!

In the transition deposit:

  • Check whether the value of owner and _sender variables are the same using builtin eq keywords.
  • Store the result in a variable named sender_is_owner
  • Your Workspace

    Show Solution

    Solution

    1

    2

    3

    4

    5

    6

    7

    8

    9

    scilla_version 0
    import BoolUtils
    contract SocialMediaPayment (owner: ByStr20)
    transition deposit()
    (* Start typing from the line below. The answer will be a single line within the transition so you won’t need to use semicolon at the end*)
    sender_is_owner = builtin eq _sender owner
    end
    scilla_version 0
    import BoolUtils
    
    contract SocialMediaPayment (owner: ByStr20)
    
    transition deposit()
      (* Start typing from the line below. The answer will be a single line within the transition so you won’t need to use semicolon at the end*)
    
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9