Crates.io | ckb-std |
lib.rs | ckb-std |
version | |
source | src |
created_at | 2020-03-25 07:38:49.968822+00 |
updated_at | 2025-03-14 09:09:18.988549+00 |
description | This library contains serveral modules help you write CKB contract with Rust |
homepage | |
repository | https://github.com/nervosnetwork/ckb-std |
max_upload_size | |
id | 222581 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This library contains several modules that help you write CKB contract with Rust.
syscalls
module: defines CKB syscallshigh_level
module: defines high level APIsdynamic_loading
module: dynamic loading primitivesdebug!
macro: a println!
like macro helps debuggingentry!
macro: defines contract entry pointdefault_alloc!
macro: defines global allocator for no-std rustdummy_atomic
module: dummy atomic operationslogger
module: colored logger implementationtype_id
module: Type ID implementation (feature type-id
)Default allocator uses a mixed allocation strategy:
User can invoke macro with arguments to customize the heap size. The default heap size arguments are:
(fixed heap size 4KB, dynamic heap size 516KB, dynamic heap min memory block 64B)
Use the macro with arguments to change it:
default_alloc!(4 * 1024, 516 * 1024, 64)
Beware, use difference heap size or memory block size may affect the verification result of the contract, some runtime errors such as out of memory may occur; you should always test the contract after customizing.
Check examples
and tests to learn how to use.
See also ckb-tool which helps you write tests.
Starting from ckb-std 0.16.0, RISC-V atomic instructions are generated by default. However, ckb-vm doesn't directly support atomic instructions. To address this, ckb-std provides the following solutions:
-C target-feature=-a
to RUSTFLAGS
For more detailed information on compilation flags, refer to the CKB Script Templates repository.