The simply introduce of local script¶
The local callback script also applies to this language and syntax, but you don’t need to follow the format of the contract and return a table at the script end to define global variables.
When the local callback script is executed, the code is executed sequentially in the script.
A simple script¶
pprint("got event ", event_type, " from contract ", contract_id（the contract ID where emit triggers the code）, " param is ", param)
Global variable for local script¶
truncated: whether the parameters thrown by the emit are truncated param: the parameters of the string format thrown in the emit contract_id: the contract ID where emit triggers the code event_type: event type in string format
Module used in local script¶
Local scripts can use the require function to introduce modules of the built-in libraries to use these modules in scripts
let http = require 'http' http.listen('127.0.0.1', 3000) -- Listen for HTTP requests on 3000 port
Add script to a contract¶
Operation button operation in the control platform of block chain or interface.
Use the command “compile_script ‘Script origin file path’” to compile
Use the command “add_script ‘Script compiled file path’ ‘description string’” to register the local script to the chain