/zklink_sdk

Primary LanguageRustOtherNOASSERTION

build status License
ZkLink SDK is an open-source cross-platform library that implements low-level cryptographic wallet functionality for ZkLink and Ethereum-based blockchain networks. The codebase is primarily in Rust and provides cross-language bindings using multiple tools:

  • uniffi-bindgen-go is used to generate bindings for Golang.
  • wasm-bindgen is used to generate bindings for JavaScript and TypeScript to facilitate interactions with the Wasm modules (for web browser extensions or other web-related apps).

Pre-requisites

Naturally, you will need the [Rust toolchain] installed. Besides that, for Golang binding, you will need the Golang formatters:

make prepare_ffi

For the JavaScript-Wasm bindings, you will need the wasm-pack to be installed:

make prepare_wasm

Generate Golang binding

Just use one make command to build the dynamic library and generate the Golang file

make build_go

The dynamic and static system library zklink_sdk will be in ./target/release/lib. The default binding path is ./bindings/generated, if you want to generate bindings to another directory, just set the BINDINGS_DIR when run the make command:

BINDINGS_DIR=/path/to/the/bindings/directory make build_go

To use the bindings and the library, see the detail in make test_go and make run_exampl_gocommand.

Generate Python binding

As the Golang binding, just use make command to build the dynamic library and generate the Python file:

make build_python

You can find the generated Python file in ./bindings/generated, if you want to generate bindings to another directory, just set the BINDING_DIR when run the make command:

BINDINGS_DIR=/path/to/the/bindings/directory make build_python 

In order to use the the zklink_sdk, you need to put the dynamic file to the same directory of your code. For example, you run can run the Python examples:

make copy_lib_to_py_example run_example_python

Generate Wasm bindings

make build_wasm