A project to help developers writing script in Lua on CKB-VM.
make all-via-dockerThere 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_worldThere 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
-eis used to evaluate some lua script. For example, runningckb-debugger --bin ./build/lua-loader.debug -- -e 'print("abcdefg")'will print outabcdefgin to console.-fis used to enable file system access. For example, runningckb-debugger --bin ./build/lua-loader.debug -- -fwould evaluate themain.luafile within the file system in the cell data.-ris used to execute coded loaded from ckb-debugger. For example, runningckb-debugger ---read-file strings.lua --bin ./build/lua-loader.debug -- -rwill 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-fileparameter ofckb-debugger) to facilitate testing of running local lua files.