# Tutorial

# Development Process

Start IDE

Usually we carry out development and debugging on the test chain. When the development test is completed, we deploy it to the official chain.

what do you need:

  1. Development environment
  2. Official chain account and a certain number of tokens

# 1. Development environment

  1. First download the latest version of AnyChain IDE (opens new window)
  2. Unzip directly run AnyChain.exe program, open the IDE.
  3. The first time you start, you will be prompted to set the path of the data directory, and you can select the appropriate path according to your actual situation.
  4. After entering the IDE main interface, select the "File" -> "Configuration" menu, you can set the language to Chinese, and set the startup type to "Test Chain". Click the "Confirm" button and restart the IDE.
  5. After entering the IDE again, the test chain has been run, and there is a default account that stores enough tokens for testing.

# 2. Your first gluta program

After entering the IDE main interface, click the first icon in the toolbar to create a new program file. At this time, a dialog box will pop up. Select the appropriate file path in the dialog box and enter the file name. Then click the confirm button. At this time a default contract template will be automatically generated. You can use the template code directly, or you can enter the following example code:

type Storage = {
    -- insert new storage properties here
}

var M = Contract<Storage>()

function M:init()
    print("初始化")
    -- insert init code of contract here
end

-- offline Key workd - API Execution does not be on chain.
offline function M:hello(arg: string)
    emit hello(arg)
    return("hello "..arg)
end

# 3. Compile, register and call

  1. Click the "Compile" button on the toolbar to complete the code compilation, generate a ".gpc" file and output the path where the file is located.
  2. Click the "Register" button on the toolbar to register the compiled contract code on the chain. Note that in the pop-up dialog box, select the correct contract code file. Record the information returned contract_id.
  3. Click the "Console" button on the toolbar and execute the following statement (please replace contract_id with actual value).
    invoke_contract_offline "nathan" "contract_id" "hello" "123"
  1. The console output is as follows:
    >>>invoke_contract_offline "nathan" "HXTCQtETHn1MUjN3hJNTmWKe9gwFrZWFH12mN" "hello" "123"
    {
        "id": 2192,
        "jsonrpc": "2.0",
        "result": "hello 123"
    }

Through the above simple steps, we have created a smart contract and registered it on the test chain. Finally, by calling the interface of the smart contract, we obtain the desired output.

# 4. Start to write smart contracts with gula

Through the above simple example we have an intuitive feeling. The development process of smart contracts is very simple. The development of actual applications requires complex business logic, and may also require more complex data structures and control processes. Here you can refer to the specific grammar reference document.

Language Reference

# 5. Write application

Merely developing smart contracts cannot fully meet user needs. For ordinary users, a simple and easy-to-use interface is necessary, so in addition to developing smart contracts, a productized DAPP also needs an application terminal for product words. For the application program, the smart contract API can be accessed through the standard RPC interface. For details, please refer to the RPC command reference. You can also refer to an actual DAPP example.