Alive24 / ckb_ssri_sdk

0 stars 0 forks source link

ckb_ssri_sdk

Goals

  1. Easier definitions and implementations of SSRI namespacing;
  2. Unified entry function;

Execution Environment Levels

Usage

  1. SSRI-Compliant Smart Contract Code would have an identifier Type that also implements TypeID mechanism.
  2. SSRI-Compliant Smart Contract would use the unified entry function to run the script and call the exposed methods by specifying the path at argv[0] and the arguments at argv[1..].
    • The default namespace is SSRI which consists of:
      • SSRI.version() -> u8
      • SSRI.get_methods(offset: u64, limit: u64) -> Vec<Bytes8>
      • SSRI.has_methods(methods: Vec<Bytes8>) -> Vec<bool>
    • By using the #[ssri_module] macro and #[ssri_method] attribute, the developer can define their own namespace and methods and automatically expose them in the methods of the default namespace SSRI.
  3. By implementing traits from ckb_ssri_sdk::public_module_traits in the SSRI-Compliant Smart Contract, infrastructures would be able to provide richer information off-chain as well for all kinds of purposes based on the SSRI protocol.
echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "run_script",
    "params": ["<TxHash of the target Cell>", <Index>, [<Bytes of methods path>, <...argv>]]
}'

Defining a SSRI Module

[ssri_module]

[ssri_method]

Defining a SSRI Public Module Trait