Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Oct 23, 2019
1 parent bb0772a commit 1b83c94
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/ackermann.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It grows very quickly in value, as does the size of its call tree. The Ackermann
\end{cases}
nCrypt has devised to way to calculate the value of the Ackermann function using `native scripts`_. But it is definitely non-trivial. Below we present a much simpler version.
nCrypt has devised a way to calculate the value of the Ackermann function using `native scripts`_. But it is definitely non-trivial. Below we present a much simpler version.

.. code-block:: solidity
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sCrypt is designed to facilitate writing smart contract running on chain.

* It is easy to learn. Syntactically, sCrypt is similar to Solidity, making it easier to be adopted by existing smart contract developers. However, the resemblance is only superficial, since sCrypt is compiled into Bitcoin Script by the underlying compiler, instead of EVM bytecode.
* It is statically typed. Type checking can help detect many errors at compile time.
* It comes with a full-fledged `IDE <http://scrypt.studio>`_, including editor, compiler, and debugger. The first version is web based, no installation required to start playing immediately.
* It comes with a full-fledged `IDE <http://scrypt.studio>`_, including editor, compiler, interpreter, and debugger. The first version is web based, no installation required to start playing immediately.


.. Warning:: sCrypt is still in experimental phase and not ready for production use.
Expand Down
31 changes: 16 additions & 15 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
A Simple Smart Contract
=======================

A contract consists of two parts: locking script and unlocking script.
Contract in sCrypt is conceptually similar to class in Object Oriented Programming.
Each contract provides a template for a certain type of contracts (e.g., P2PHK or multisig), which can be instantiated into concrete runnable contract objects.

.. code-block:: solidity
contract Test {
int x;
constructor() {
x = 10;
constructor(int _x) {
x = _x;
}
public function equal(int y) {
Expand All @@ -20,34 +21,34 @@ A contract consists of two parts: locking script and unlocking script.
Constructor
===========
Each contract has one and only one constructor. It is where contract member variables are initialized.
Each contract has at most one constructor. It is where contract member variables are initialized.
For example, it can initialize the public key hash of a P2PHK contract, or the hash of a secret in a hash puzzle contract.

require
=======
The ``require`` function specifies terms/conditions of the contract. It consumes a boolean condition and will abort the execution of a contract if the condition is not met.
Otherwise, it will continue the execution.
require()
=========
The ``require()`` function specifies terms/conditions of a contract. It consumes a boolean condition and will abort the execution of a contract if the condition is not met.
Otherwise, the execution will resume.

Public Function
=================
Each contract has at least one public function. It is denoted with the ``public`` keyword and does not return any value. The function body corresponds to unlocking script (commonly referred to as ``scriptPubKey``) and its arguments locking script (aka, ``scriptSig``).
It is visible outside the contract, similar to ``public`` function in Solidity. It acts as the entry point into the contract from the outside (like ``main`` in ``C`` and ``Java``). A contract can only be fulfilled and successfully complete when its public function succeeds.
It is visible outside the contract and acts as the entry point into the contract (like ``main`` in ``C`` and ``Java``).

A public function must end with a ``require`` call. ``require`` can also appear in other parts of a public function. A public function only succeeds if it runs to completion without violating any condition in ``require``.
In the above example, ``scriptSig`` of ``10`` can fulfill the contract.
A public function must end with a ``require()`` call. ``require()`` can also appear in other parts of a public function. A contract can only be fulfilled and succeed when its called public function runs to completion without violating any conditions in ``require()``.
In the above example, only ``scriptSig`` (i.e., ``y``) equal to ``_x`` can fulfill the contract.

Multiple Public Functions
---------------------------
A contract can have multiple public functions, representing different ways to fulfill a contract. Only one of the public functions can be chosen at a time. In this case, the last operator of ``scriptSig`` has to be the index of the public function chosen, starting from 1.
For example, if ``larger`` public function path is chosen, the ``scriptSig`` of ``11 3`` can fulfill the contract below, in which ``3`` is the public function index.
A contract can have multiple public functions, representing different ways to fulfill a contract. Only one of the public functions can be called at a time. In this case, the last operator of ``scriptSig`` has to be the index of the public function called, starting from ``1``.
For example, if public function ``larger`` is called, ``scriptSig`` of ``y 3`` can fulfill the contract below, in which ``3`` is the public function index.

.. code-block:: solidity
contract Test {
int x;
constructor() {
x = 10;
constructor(int _x) {
x = _x;
}
public function equal(int y) {
Expand Down
2 changes: 1 addition & 1 deletion docs/rpuzzle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ R-Puzzle
In R-puzzle, an ephemeral key ``k`` is never revealed. Instead ``r``, the x coordinate its its corresponding public key,
is revealed and from ``r`` along with the signature, the knowledge of ``k`` can be proved using existing ``checkSig``.

One crucial in R-Puzzle is to extract ``r`` from `DER`_ encoded signature. The following is much easier than what is presented in the `R-Puzzle`_ talk.
One crucial step in R-Puzzle is to extract ``r`` from `DER`_ encoded signature. The following is much easier than what is presented in the `R-Puzzle`_ talk.

.. code-block:: solidity
Expand Down
4 changes: 2 additions & 2 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Types
Basic Types
-----------

* **bool** - a boolean value.
* **int** - a 32-bit signed integer. Literals of this type can be specified in dec or hex.
* **bool** - a boolean value ``true`` or ``false``.
* **int** - a signed integer of arbitrary length. Literals of this type can be specified in dec or hex.

.. code-block:: solidity
Expand Down

0 comments on commit 1b83c94

Please sign in to comment.