Skip to content

A simple and beginner-friendly documentation for Sophia

Notifications You must be signed in to change notification settings

YinkaEnoch/sophia-for-beginners

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Introduction

Sophia is a functional language used in writing smart contracts on the aeternity block chain. The language is strongly typed, which means the compiler checks for syntax errors during compilation. Sophia uses Python-style layout rules to group declarations and statements. Blocks with a single element can be written on the same line as the previous token. Each element of the block must share the same indentation and no part of an element may be indented less than the indentation of the block.

Check out the Official Definition

Sophia Layout Blocks

Comment

Sophia supports both the single line and multi-line comment (or block comment).

Single line comment starts with //

This example uses a single line comment


// The function checks if a name exist in the state record

entrypoint nameExists(name: string) : bool =
      Map.member(name, state.hamsters)

Multi-line comments start with /* and end with */

This example uses a multi-line comment

/*
* Checks if a name exists in the state record
* @param {string} name
* @returns {bool} 
*/

entrypoint nameExists(name: string) : bool =
    Map.member(name, state.hamsters)

Variables

Variables are declared in Sophia by the keyword let

let x: int = 4

let userAddress: address = Call.caller

let name: string = 'YinkaEnoch'

Reserved Keywords

The following words cannot be used as variables or function names

  • contract
  • elif
  • else
  • entrypoint
  • false
  • function
  • if
  • import
  • include
  • let
  • mod
  • namespace
  • private
  • payable
  • stateful
  • switch
  • true
  • type
  • record
  • datatype

About

A simple and beginner-friendly documentation for Sophia

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published