# Smart Contract Overview
# Summoner Introduction
Summoner is a high-level programming language similar to golang
. It is specially used to write contract programs running on Bytom 2.0. The main characteristics of the contract are as follows:
- Similar to
golang
, The basic syntax and program structure are all likegolang
- Statically typed, which means that the type of each variable (state and local) needs to be specified
- Bytom adopts BUTXO model. Each BUTXO includes asset amount, asset id and script .script contain program and data,BUTXO get global status from data
# Structure of a Summoner Contract
The contract consists of the following elements:
- Statement, declare the global library, which is not available in the current version
- Global variable definition, define global data types
- Function definition (Declaration), define (declare) functions
A Summoner program consists of a contract, which consists of global state data and functions. The contract is defined as follows:
var (variables)
func functionName(parameters) {statements}
var
is the keyword,indicating variable definition; variables
is the variable definition list, which represents the global stats data list of the contract
func
is the keyword, indicating function definition, Each function describes the unlocking method of contract locked assets. A contract can have multiple functions.
functionName
is the identifiers, indicating the function name
parameters
indicates the list of function parameters;
function body is built by many statements
, which can be declaration statement, expression statement, build-in statements including verify
and lock
Examples are as follows:
var a int64 = 12345678
func globalParaAdd(b int64) {
a = a + b
}