github.com/aergoio/aergo@v1.3.1/cmd/brick/example/hello.lua (about)

     1  -- Define global variables.
     2  state.var {
     3    Name = state.value()
     4  }
     5  
     6  -- Initialize a name in this contract.
     7  function constructor()
     8    -- a constructor is called at a deployment, only one times
     9    -- set initial name
    10    Name:set("world")
    11  end
    12  
    13  -- Update a name.
    14  -- @call
    15  -- @param name          string: new name.
    16  function set_name(name)
    17    Name:set(name)
    18  end
    19    
    20  -- Say hello.
    21  -- @query
    22  -- @return              string: 'hello ' + name
    23  function hello()
    24    return "hello " .. Name:get()
    25  end
    26    
    27   -- register functions to expose
    28  abi.register(set_name, hello)