sCrypt is a strongly typed language. The basic data types include:
bool
: boolean value, true
or false
int
: signed integer
int[3]
: Integer array of size 3
PubKey
: public key
Sig
: signature
Among them, PubKey
and Sig
are subtypes of bytes
.
Each contract can have several properties, which can be accessed through the this
keyword in the function of the contract, as in Object-Oriented languages:
contract Test { int x; bool y; bytes z; public function unlock(int y) { require(this.x == y); } }
The Tic-Tac-Toe game contract supports two players. The contract needs to save the addresses of the two players. After the contract runs, the contract automatically sends the locked bitcoin to the winner unless the game ends in draw.
alice
and bob
, the data types are both PubKey
.