{"id":18674116,"url":"https://github.com/nervosnetwork/ckb-std","last_synced_at":"2025-08-22T08:31:37.161Z","repository":{"id":45057248,"uuid":"231067723","full_name":"nervosnetwork/ckb-std","owner":"nervosnetwork","description":"This library contains serveral modules that could help you write CKB contract with Rust.","archived":false,"fork":false,"pushed_at":"2024-04-02T12:16:35.000Z","size":6601,"stargazers_count":20,"open_issues_count":1,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-14T09:19:15.012Z","etag":null,"topics":["ckb","contract","nervos","rust","syscall"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nervosnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-12-31T09:58:15.000Z","updated_at":"2024-04-14T07:58:34.000Z","dependencies_parsed_at":"2024-01-01T10:33:02.332Z","dependency_job_id":"17674d46-94c4-44a8-8500-b14c8f51dfd7","html_url":"https://github.com/nervosnetwork/ckb-std","commit_stats":{"total_commits":196,"total_committers":10,"mean_commits":19.6,"dds":"0.38265306122448983","last_synced_commit":"4c441bf4360eef67c2dd90006970c9f78f938ae8"},"previous_names":["jjyr/ckb-contract-std"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-std","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-std/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-std/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fckb-std/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nervosnetwork","download_url":"https://codeload.github.com/nervosnetwork/ckb-std/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230532452,"owners_count":18240792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ckb","contract","nervos","rust","syscall"],"created_at":"2024-11-07T09:17:33.314Z","updated_at":"2024-12-20T11:08:03.389Z","avatar_url":"https://github.com/nervosnetwork.png","language":"Rust","readme":"# ckb-std\n[![Crates.io](https://img.shields.io/crates/v/ckb-std.svg)](https://crates.io/crates/ckb-std)\n\nThis library contains several modules that help you write CKB contract with Rust.\n\n## Usage\n\n[Documentation](https://docs.rs/ckb-std)\n\n### Modules\n\n* `syscalls` module: defines [CKB syscalls](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0009-vm-syscalls/0009-vm-syscalls.md)\n* `high_level` module: defines high level APIs\n* `dynamic_loading` module: dynamic loading primitives\n* `debug!` macro: a `println!` like macro helps debugging\n* `entry!` macro: defines contract entry point\n* `default_alloc!` macro: defines global allocator for no-std rust\n* `dummy_atomic` module: dummy atomic operations\n* `logger` module: colored logger implementation\n* `type_id` module: Type ID implementation (feature `type-id`)\n### Memory allocator\n\nDefault allocator uses a mixed allocation strategy:\n\n* Fixed block heap, only allocate fixed size(64B) memory block\n* Dynamic memory heap, allocate any size memory block\n\nUser can invoke macro with arguments to customize the heap size. The default heap size arguments are:\n\n(fixed heap size 4KB, dynamic heap size 516KB, dynamic heap min memory block 64B)\n\nUse the macro with arguments to change it:\n\n``` rust\ndefault_alloc!(4 * 1024, 516 * 1024, 64)\n```\n\n\u003e 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.\n\n### Examples\n\nCheck `examples` and [tests](https://github.com/nervosnetwork/ckb-std/blob/master/contracts/ckb-std-tests) to learn how to use.\n\nSee also [ckb-tool](https://github.com/nervosnetwork/capsule/tree/develop/crates/testtool) which helps you write tests.\n\n\n### Upgrading Issues\n\nStarting from ckb-std 0.16.0, RISC-V atomic instructions are generated by\ndefault. However, ckb-vm doesn't directly support atomic instructions. To\naddress this, ckb-std provides the following solutions:\n\n1. Use the \"dummy-atomic\" feature (enabled by default)\n2. Adjust Rust compilation flags by adding `-C target-feature=-a` to `RUSTFLAGS`\n\nFor more detailed information on compilation flags, refer to the [CKB Script Templates repository](https://github.com/cryptape/ckb-script-templates/tree/main?tab=readme-ov-file#molecule-uses-bytes-crates).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fckb-std","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnervosnetwork%2Fckb-std","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fckb-std/lists"}