A lightweight, WebAssembly-native Canister Development Kit for building smart contracts on the Internet Computer with MoonBit.
Features • Quick Start • Documentation • Examples • Contributing • License
moonbit-ic-cdk is a MoonBit Canister Development Kit designed for the Internet Computer (ICP). It provides a complete set of API bindings and utilities that enable developers to build high-performance, compact smart contracts using the MoonBit language.
MoonBit is a programming language and toolchain optimized for WebAssembly (WASM), designed for modern cloud and edge computing. It compiles into compact, high-performance WASM binaries with exceptional compile-time and runtime efficiency.
Advantages of MoonBit for ICP Canister Development:
- 🚀 High Performance - Built for WebAssembly from the ground up, generating compact and efficient binaries
- 🎯 Developer Friendly - Easier to learn than Rust with clean and intuitive syntax
- ⚡ Lightweight - Low runtime overhead, perfect for resource-constrained smart contract environments
- 🔧 Strong Compatibility - Seamless integration with IC system APIs
-
✅ Complete IC System API Bindings
- Low-level
ic0FFI bindings - High-level system API abstractions
- Principal type and utility functions
- Low-level
-
✅ Complete Candid Serialization/Deserialization
- Support for all Candid primitive types
- LEB128 encoding/decoding support
- Candid IDL builder
- Type-safe encoders and decoders
-
✅ HTTP Request/Response Handling
- HTTP service Canister support
- Request/response type definitions
- Compliant with IC HTTP Gateway interface specification
-
✅ Storage and Memory Management
- Stable memory APIs
- Storage utility functions
- Low-level memory operations
- ✅ Phase 1: Core ICP types and system API support
- ✅ Phase 2: Candid serialization/deserialization and HTTP APIs
- 🚧 Phase 3: Management Canister API, inter-canister calls, JSON serialization, etc. (In Progress)
Linux & macOS:
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bashWindows (PowerShell):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm https://cli.moonbitlang.com/install/powershell.ps1 | iexgit clone https://github.com/eliezhao/moonbit-ic-cdk.git
cd moonbit-ic-cdk# Navigate to example directory
cd examples/demo
# Build with MoonBit
moon build --target wasm --release# Deploy Canister (replace YOUR_CANISTER_ID with your actual canister ID)
dfx canister --ic install YOUR_CANISTER_ID \
--wasm target/wasm/release/build/demo/demo.wasm
# Or use dfx deploy for local development
dfx deploymoonbit-ic-cdk/
├── ic0.mbt # Low-level FFI bindings to IC system API
├── system_api.mbt # High-level system API abstractions
├── ic_principal.mbt # Principal type and utility functions
├── candid_*.mbt # Candid serialization/deserialization implementation
├── http_*.mbt # HTTP request/response handling
├── leb128.mbt # LEB128 encoding/decoding
├── unsafe.mbt # Low-level memory operations
└── examples/ # Example code
├── basic/ # Basic usage examples
└── demo/ # Complete Canister example
ic0.mbt- Direct WebAssembly interface for interacting with the Internet Computersystem_api.mbt- Provides convenient wrappers for common IC operations, inspired by Rust'sic-cdkic_principal.mbt- Implements thePrincipaltype for representing identities (users, canisters) on the Internet Computercandid_*.mbt- Complete Candid codec implementation including types, encoders, and decodershttp_*.mbt- Types and utilities for building HTTP service canistersleb128.mbt- Integer serialization support for Candid
Check out the examples/basic/ directory to learn about core CDK features and API usage.
The examples/demo/ directory contains a complete Canister example demonstrating:
- Message handling and replies
- Principal retrieval and encoding
- HTTP request processing
- Candid serialization/deserialization
Run the example:
cd examples/demo
moon build --target wasm --release
dfx deploy
# For production deployment to IC mainnet:
# dfx canister --ic install YOUR_CANISTER_ID --wasm target/wasm/release/build/demo/demo.wasm- IC system API bindings (
ic0,ic0-warp) - MoonBit Canister successfully deployed on Internet Computer
- Complete Candid codec implementation
- LEB128 encoding/decoding support
- HTTP request/response handling
- Stable memory and storage APIs
- Candid IDL builder
- Management Canister API support
- Inter-canister calls
- JSON serialization/deserialization
- Async message support (pending MoonBit async/await primitives)
- More advanced CDK APIs (certified data, traps, cycles management, etc.)
We welcome all forms of contributions! Whether it's reporting issues, suggesting features, or submitting code improvements, your participation makes this project better.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Run
moon fmtto format your code - Run
moon infoto update generated interface files - Run
moon testto run tests - Run
moon checkto check code linting
For more detailed information, please refer to AGENTS.md.
- 📚
moonbit-ic-cdkhas been officially included in the awesome-internet-computer curated list maintained by DFINITY - 💬 Join the discussion on the DFINITY Developer Forum and share your feedback and ideas
- 🤝 We are collaborating with the MoonBit core development team to jointly promote ICP adoption in the MoonBit ecosystem
This project is licensed under the Apache License 2.0.
- MoonBit Official Website
- Internet Computer Documentation
- DFINITY Developer Forum
- Awesome Internet Computer
Made with ❤️ by the MoonBit IC CDK community