ckb-std 0.4.1

This library contains serveral modules help you write CKB contract with Rust
docs.rs failed to build ckb-std-0.4.1
Please check the build logs and, if you believe this is docs.rs' fault, open an issue.
Visit the last successful build: ckb-std-0.1.6

ckb-std

Crates.io

This library contains serveral modules that help you write CKB contract with Rust.

Usage

Documentation

Modules

  • syscalls module: defines CKB syscalls
  • high_level module: defines high level APIs
  • debug! macro: a println! like macro helps debugging
  • entry! macro: defines contract entry point
  • default_alloc! and libc_alloc! macro: defines global allocator for no-std rust

Memory allocator

Default allocator uses a mixed allocation strategy:

  • Fixed block heap, only allocate fixed size(64B) memory block
  • Dynamic memory heap, allocate any size memory block

User can invoke macro with arguments to customize the heap size. The default heap size arguments are:

(fixed heap size 4KB, dynamic heap size 64KB, dynamic heap min memory block 64B)

Use the macro with arguments to change it:

default_alloc!(4 * 1024, 64 * 1024, 64)

Beware, use difference heap size or memory block size may affect cycles of the contract; you should always test the contract after customizing parameters.

Examples

Check examples and tests to learn how to use.

See also ckb-tool which helps you write tests.