Dubhe CLI for Sui
Before getting started with Dubhe CLI, please install the required dependencies:
pnpm install -D @0xobelisk/sui-cli @0xobelisk/sui-common
Note: @0xobelisk/sui-common contains essential configuration type definitions like DubheConfig.
The Dubhe CLI
The Dubhe CLI is a development toolkit for building and managing Dubhe projects on the Sui blockchain.
Core features:
schemagen
: Generate Dubhe schemas automatically from your store schemas configurationpublish
: Deploy your Dubhe projects to any Sui network (mainnet/testnet/devnet/localnet)upgrade
: Upgrade your Dubhe Move contractsnode
: Manage local Sui node for developmentfaucet
: Interface with Sui faucets to fund addresses on testnet/devnet/localnetgenerate-key
: Generate a new account key pair and save it to a .env filecheck-balance
: Check the balance of the accountconfig-store
: Store configuration for the Dubhe projectbuild
: Build Dubhe Move contractstest
: Run tests for Dubhe contractsdoctor
: Check development environment and install required toolswait
: Wait for services to be readywatch
: Watch configuration file for changesswitch-env
: Switch between different network environmentsconvert-json
: Convert Dubhe config to JSON formatload-metadata
: Load package metadatainfo
: Display account and network information
Installation
The CLI should be installed as a project dependency rather than globally. When you create a new project using pnpm create dubhe
, the CLI is automatically added as a dev dependency.
Using the CLI
Some commands expect a dubhe config in the same folder where the CLI is being executed. This includes schemagen
and publish
.
faucet
and node
can be executed anywhere.
Commands
schemagen
Generate Store libraries from a dubhe.config.ts
file. See the Store Config and schemagen
documentation in the Store section for more details.
dubhe schemagen [--config-path <path>] [--network <network>]
Options:
--config-path Path to config file (default: "dubhe.config.ts")
--network Target network (mainnet/testnet/devnet/localnet)
publish
Deploy Dubhe contracts to Sui network. This tool will use the dubhe.config.ts
to detect all systems and schemas to deploy them to the specified network.
Before deploying the contract, please ensure:
- You have sufficient tokens in your account for deployment fees
- For testnet/devnet/localnet deployments, you can get test tokens via
dubhe faucet
- For localnet deployments, ensure your local node is running
dubhe publish --network <network> [--config-path <path>] [--gas-budget <number>]
Options:
--network Target network (mainnet/testnet/devnet/localnet) (default: localnet)
--config-path Path to config file (default: "dubhe.config.ts")
--gas-budget Optional gas budget for transaction
upgrade
Upgrade deployed Dubhe contracts.
dubhe upgrade --network <network>
Options:
--network Target network (mainnet/testnet/devnet/localnet)
--config-path Path to config file (default: "dubhe.config.ts")
node
Manage local Sui node using the official sui
binary.
dubhe node [--data-dir <path>] [--force]
Options:
--data-dir Path to the data directory (default: ".chk")
--force Force restart: stop existing node and remove data directory (default: false)
Local RPC endpoint: http://127.0.0.1:9000
Note: Make sure your local node is running properly before using other commands that require a local node (e.g., dubhe publish --network localnet
).
faucet
Request test tokens from the Sui faucet. The default faucet service automatically gives test tokens to accounts in .env
.
dubhe faucet --network <network> [--recipient <address>]
Options:
--network Network to request tokens on (testnet/devnet/localnet) (default: localnet)
--recipient Optional recipient address (uses PRIVATE_KEY env if not specified)
generate-key
Generate new account keypair.
dubhe generate-key [--force] [--use-next-public]
Options:
--force Force generate new keypair (default: false)
--use-next-public Use NEXT_PUBLIC_ prefix for client-side usage (default: false)
check-balance
Check account balance on specified network.
dubhe check-balance --network <network>
Options:
--network Network to check balance on (mainnet/testnet/devnet/localnet) (default: localnet)
config-store
Store configuration for the Dubhe project.
dubhe config-store --network <network> [--config-path <path>] [--output-ts-path <path>]
Options:
--network Network to store config for (mainnet/testnet/devnet/localnet)
--config-path Path to config file (default: "dubhe.config.ts")
--output-ts-path Output path for generated TypeScript config (e.g., ./src/config/generated.ts)
build
Build your Dubhe Move contracts.
dubhe build --network <network> [--config-path <path>] [--dump-bytecode-as-base64]
Options:
--network Target network (mainnet/testnet/devnet/localnet)
--config-path Path to config file (default: "dubhe.config.ts")
--dump-bytecode-as-base64 Output bytecode as base64
test
Run tests for Dubhe contracts.
dubhe test [--config-path <path>] [--test <test_name>] [--gas-limit <limit>]
Options:
--config-path Path to config file (default: "dubhe.config.ts")
--test Name of specific test to run
--gas-limit Set gas limit for test (default: "100000000")
doctor
Check development environment and install required tools automatically.
dubhe doctor [--install-all]
Options:
--install-all Automatically install all missing tools (default: false)
The doctor command checks for:
- Node.js version compatibility
- Docker service availability
- Required development tools (sui, postgres, etc.)
- Port availability for local services
- Network connectivity
wait
Wait for service(s) to be ready before proceeding.
dubhe wait [--url <url>] [--localnet] [--timeout <ms>] [--interval <ms>]
Options:
--url URL to wait for (single service)
--localnet Wait for all dubhe localnet services (default: false)
--timeout Timeout in milliseconds (default: 180000)
--interval Check interval in milliseconds (default: 1000)
Examples:
- Wait for a specific service:
dubhe wait --url http://localhost:4000
- Wait for all localnet services:
dubhe wait --localnet
watch
Watch configuration file for changes and automatically run schemagen.
dubhe watch
This command monitors dubhe.config.ts
for changes and automatically runs dubhe schemagen
when the file is modified.
switch-env
Switch between different network environments.
dubhe switch-env --network <network>
Options:
--network Target network (mainnet/testnet/devnet/localnet) (default: localnet)
convert-json
Convert Dubhe configuration to JSON format.
dubhe convert-json [--config-path <path>] [--output-path <path>]
Options:
--config-path Path to config file (default: "dubhe.config.ts")
--output-path Output path for JSON file (default: "dubhe.config.json")
load-metadata
Load package metadata for a deployed contract.
dubhe load-metadata --network <network> [--config-path <path>] [--package-id <id>]
Options:
--network Network to use (mainnet/testnet/devnet/localnet) (default: localnet)
--config-path Path to config file (default: "dubhe.config.ts")
--package-id Package ID to load metadata for (optional)
info
Display account and network information.
dubhe info --network <network>
Options:
--network Network to check (mainnet/testnet/devnet/localnet) (default: localnet)
This command shows:
- Current network
- Account address
- Account balance
Environment Setup
Some commands require environment variables to be set:
PRIVATE_KEY
: Required for deployment and some other operations- Can be set up using a
.env
file in your project root
When using the deployer, you must set the private key of the deployer using the PRIVATE_KEY
environment variable. You can make this easier by using dotenv
before running commands.
Network Support
The CLI supports the following networks:
- Mainnet
- Testnet
- Devnet
- Localnet
For testnet/devnet/localnet operations, you can get test tokens using the faucet
command.