Syntax
Syntax in Zetrix smart contract
Overview
Zetrix smart contracts are written in the 'JaveScript'. In order to facilitate developers to develop a more standardized and safer contract, JSLint is used to check the syntax in smart contracts.
The standard syntax of JSLint is described in detail on the official website. The purpose of this document is to refine the original JSLint syntax rules as a complete document, and to supplement Zetrix's modified rules. The documentation will illustrate its usage with examples.
you can visit the manual at this site: 127.0.0.1:36002/jslint/help.html by node servers or wallet addresses.
Detection Tool
you can visit 127.0.0.1:36002/jslint/index.html by node servers or wallet addresses.
For error description, details will be given when you debug contract syntax in the web tool. When you input the following code:
Error is shown below:
Cause: Blank statement block at row 2 and column 0.
Correct code is shown below:
If the result is correct, no warning information will prompt.
Text Compression
After the contract document is written, you can use the JSMin tool to compress it. Ensure that the original document is saved because compression is an irreversible operation.
Demo
Rules List
Detect the statement strictly with all source code added the
'use strict'
field at the beginningUse
let
to declare variables within a statement blockUse
===
instead of==
to judge the comparison; use!==
instead of!=
to compareA statement must end with
;
A statement block must be enclosed with
{}
and empty statement blocks are prohibitedThe initial variable of the
for
loop variable needs to be declared before the conditional statement block, and a new value is assigned to it when usedUse
+=
and-=
to substitute++
and--
Prohibit to use keywords like
eval
andvoid
Prohibit to use
new
to createNumber
,String
andBoolean
objects, which objects can be obtained by calling their constructorsProhibit to create an array with array keywords
Prohibit to use keywords like
try
andcatch
, but you can usethrow
to throw exceptions
Keywords prohibited to use
Last updated