This repository, sui-native, is a collection of Move packages for Bitcoin Chain Abstraction, and other related Native projects, on the Sui blockchain. It enables the use of Bitcoin-related functionalities and assets within the Sui ecosystem.
Key Move packages:
bitcoin_lib/: A Move library that provides various utilities and data structures for working with Bitcoin within the Sui environment. Core Bitcoin primitives (transactions, headers, crypto)bitcoin_spv/: Simplified Payment Verification (SPV) light clientbitcoin_executor/: A trustless Bitcoin execution node on Sui, which is part of the Trustless Sui Bitcoin Node. This allows for the execution and verification of Bitcoin transactions on the Sui network.nBTC/: A Move package that implements a synthetic, 1:1 backed representation of Bitcoin on Sui. It is designed to be permissionless, custodyless, and trust-minimized. Provides nBTC coin implementation with minting/burning logic.nbtc_swap/: A simple marketplace, built with Move, to facilitate the swapping of nBTC with Sui.
The project is built using the Move programming language for the smart contracts and uses bun for managing JavaScript/TypeScript dependencies and running scripts.
Run these from within each package directory (e.g., cd nBTC && make test):
- Build:
make buildorsui move build - Test:
make testorsui move test --gas-limit 5000000 - Test with coverage:
make test-coverageorsui move test --gas-limit 5000000 --coverage - Lint:
make lint(lints modified files) ormake lint-all(lints all) - Lint fix:
make lint-fix-all(fixes markdown, formats Move) - Generate docs:
make gen-docs(builds and copies docs to docs/)
Run from repository root:
- Build all Move packages:
make build-move-all - Test all Move packages:
make test-move-all - Format all Move files:
make format-move-all - Add license headers:
make add-license(adds SPDX to .move files) - Setup git hooks:
make setup-hooks(installs pre-commit hooks and prettier)
Run from repository root:
- Install dependencies:
bun install - Type check:
bun run typecheckortsc --noEmit - Format all:
bun run format:all - Format Move files:
bun run format:move-all - Test:
bun run test - Generate TypeScript from Move:
bun run generate-ts(generates TypeScript SDK from Move contracts in sdk/src/generated)
Note: The TypeScript generation creates bindings that interact with Move contracts. After running generate-ts, the generated files will be in sdk/src/generated/. The current TypeScript configuration has verbatimModuleSyntax disabled to accommodate the generated code.
- Move packages:
bash ./contrib/run-move-tests.sh test(builds and tests all) - JS:
bun ci, thenbun run lint,bun run typecheck,bun run test
- Formatting: The project uses
prettierandprettier-movefor code formatting. All Move code should be formatted before committing. - Licensing: The project uses the MPL-2.0 license. There is a command
make add-licenseto add the license header to all source files. - Git Hooks: The project uses git hooks to enforce conventions. It is important to run
make setup-hooksafter cloning the repository. - Dependencies: The project uses
bunto manage JavaScript/TypeScript dependencies.
- Each Move module is in its own file (e.g.,
nbtc.move,light_client.move) - Test modules are separate files with
_testssuffix (e.g.,light_client_tests.move) - Documentation is generated into
docs/directories - SDK generated TypeScript code is in
sdk/src/generated/:utils/: Common utilities for interacting with Suinbtc/: TypeScript bindings for the nBTC Move package- Each Move package gets its own directory with generated TypeScript bindings
- Modules use
module package_name::module_name;syntax - Imports follow patterns like
use sui::table::{Self, Table}; - Custom imports use
use bitcoin_lib::header::BlockHeader;
- Modules: snake_case (e.g.,
light_client,nbtc) - Functions: snake_case (e.g.,
new_light_client,verify_payment) - Structs: PascalCase (e.g.,
LightClient,Transaction) - Constants: UPPER_SNAKE_CASE (e.g.,
VERSION,EInvalidDepositKey) - Error constants: Start with
E(e.g.,EInvalidDepositKey)
- Unit tests use
#[test]functions - Integration tests use
sui::test_scenariofor multi-transaction flows - Test gas limits:
--gas-limit 5000000(required for complex tests) - Test-only modules with
#[test_only]attribute - Assertions:
std::unit_test::assert_eqandassert_ref_eq - Test helpers: Separate modules for shared test utilities
- Uses Bun as test runner
- TypeScript with
tsc --noEmitfor type checking
- Gas limits are critical - tests may fail without
--gas-limit 5000000 - Shared objects must be created in
initor transferred properly - Table operations require careful key management
- Error constants are vectors of bytes, not strings
- Function visibility:
publicfor external calls,funfor internal
- Pre-commit hooks enforce formatting (setup with
make setup-hooks) - License headers are automatically added with
make add-license - Documentation is generated and copied to
docs/directories - Prettier-move is used for Move code formatting (config in
.prettier-move.json) - Markdown linting is enforced on changed files
- Run
make build-move-allandmake test-move-allbefore commits - Use
make lint-gitfor pre-commit checks - Format code with
make format-move-allbefore pushing - CI checks formatting and tests on PRs
- Sui CLI required for Move operations
- Bun for JavaScript/TypeScript tooling
- Prettier with Move plugin for formatting