Skip to content

Commit

Permalink
Added language basics section.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoblenz committed Aug 27, 2019
1 parent f588e95 commit 84fda99
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion user_guide/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ The Obsidian Smart Contract Language
======================================

.. toctree::
:maxdepth: 1
:maxdepth: 2
:hidden:

Getting Started <getting_started>
Obsidian Language Tutorial <tutorial/tutorial>
Obsidian Reference <reference/reference>
Contributing to Obsidian <contributing>


Expand Down
25 changes: 25 additions & 0 deletions user_guide/source/reference/basics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Obsidian Language Basics
==========================

Contracts, transactions, and main contracts
----------------------------------------------
Obsidian is object-oriented. A ``contract`` is like a class: it can be instantiated as many times as needed. Each contract supports operations; each one is called a ``transaction``. Transactions are akin to methods in traditional object-oriented languages. However, unlike methods, transactions either completely finish or revert. If a transaction reverts (via the ``revert`` statement), then all changes that the transaction made will be discarded.

Main contracts
-----------------
A ``main`` contract may be instantiated on the blockchain. The contract's transactions are then available for clients to invoke. Only ``main`` contracts can be deployed directly, and the Obsidian compiler expects every program to have one ``main`` contract.

Constructors
------------
Constructors must initialize all the fields of their contracts. In addition, construtors of contracts that have defined states must transition the object to a particular state. It is good practice for constructors to specify a specific state that the object will be in if possible; otherwise, generally you should declare constructors to return an ``Owned`` reference. For example:

::

contract LightSwitch {
state On;
state Off;

LightSwitch@Off() { // the resulting object will be in Off state
->Off;
}
}
7 changes: 7 additions & 0 deletions user_guide/source/reference/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Obsidian Language Reference
============================

Before using this reference guide, please read the entire tutorial first, since the reference guide uses concepts explained in the tutorial.

.. toctree::
Language Basics <basics>

0 comments on commit 84fda99

Please sign in to comment.