A project to help developers writing script in Lua on CKB-VM.
make all-via-docker
There are a lot of tests located in 'tests' folder. Before running, please install ckb-debugger described in CI scripts. Here is a "hello,world" example:
make -C tests/test_cases hello_world
There are 2 ways to use this project:
- Embedded (Recommended)
Use build/libckblua.so
as a dynamic library. See dylib.md for a detailed tutorial on how to use build/libckblua.so
.
- Standalone
Use build/lua-loader
as a script. Require hacking for further requirement.
A couple of arguments may be passed to ckb-lua-vm. If no command line arguments is passed to ckb-lua-vm, ckb-lua-vm will run the script contained in cell data, which is assumed to be a valid exectuable lua file.
The following are the supported command line arguments.
To test the ADDITIONAL_ARGUMENTS
locally, we can run ckb-debugger --bin ./build/lua-loader.debug -- ADDITIONAL_ARGUMENTS
-e
is used to evaluate some lua script. For example, runningckb-debugger --bin ./build/lua-loader.debug -- -e 'print("abcdefg")'
will print outabcdefg
in to console.-f
is used to enable file system access. For example, runningckb-debugger --bin ./build/lua-loader.debug -- -f
would evaluate themain.lua
file within the file system in the cell data.-r
is used to execute coded loaded from ckb-debugger. For example, runningckb-debugger ---read-file strings.lua --bin ./build/lua-loader.debug -- -r
will execute the lua filestrings.lua
. Normally, ckb-lua-vm can not read files from local file system, we add this parameter (along with the--read-file
parameter ofckb-debugger
) to facilitate testing of running local lua files.