Get Started

1. Development Environment

Glua can be used to write smart contracts in the blockchain and then call it, as well as the event callback script for the Achain blockchain.

While developing contracts in the chain, you can develop in the developer chain of Achain blockchain, compile glua contract source files into bytecode file, and then put the bytecode registered to Achain developer chain for getting a contract address, and access any API of this contract;

In the development of the local script, you can first compile glua contract source files into bytecode file in Achain developer chain, and then register the bytecode file to a callback script of contract, as long as block chain is synchronized to the associated event, the callback script is triggered.

When it comes to publishing to a formal chain, the steps are similar to the above, and the developer chain is primarily used for development.

See related documentation for specific compilation, registration contract, call contract, registration script, etc.

What you need:

  • The latest version of the underlying wallet node program (built-in glua compiler and interpreter)
  • Your favorite IDE

OR

  • Achain contact IDE (Recommendation: built-in underlying wallet node program)

What else you need:

  • Need to connect to the blockchain network and synchronize all data blocks (formal chain)
  • An account with enough tokens to keep the wallet open and unlocked (formal chain)

2. Your first glua program

type Person = {
    id: string default "123",
    name: string default "glua",
    age: int default 24
}

var M = Contract<Person>()

function M:init()
    let p = Person()
    pprint(p.id, p.name, p.age)
end

return M

3. Choose an IDE

We provide a glua IDE for development and the integration with blockchain which can be used to develop smart contracts. But you can also use your favorite editors, such as Visual Studio Code, Vim, etc., without special requirements. But we still recommend our IDE that we provide, because it is a customized development tools for the development of contract, which integrates a lot of function, so as to save a lots of complicated command line operations.

5. Register smart contracts with the blockchain

See also the Achain API documentation