Dubhe CLI for Aptos

Before getting started with Dubhe CLI, please install the required dependencies:

pnpm install -D @0xobelisk/aptos-cli @0xobelisk/aptos-common

Note: @0xobelisk/aptos-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 Aptos blockchain.

Core features:

  1. schemagen: Generate Dubhe schemas automatically from your store schemas configuration
  2. publish: Deploy your Dubhe projects to any Aptos network (mainnet/testnet/devnet/localnet)
  3. upgrade: Upgrade your Dubhe Move contracts
  4. localnode: Manage local Aptos node for development
  5. faucet: Interface with Aptos faucets to fund addresses on testnet/devnet/localnet
  6. test: Run tests for Dubhe contracts

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, publish and upgrade.

faucet and localnode 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>]
 
Options:
  --config-path    Path to config file (default: "dubhe.config.ts")

publish

Deploy Dubhe contracts to Aptos 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:

  1. You have sufficient tokens in your account for deployment fees
  2. For testnet/devnet/localnet deployments, you can get test tokens via dubhe faucet
  3. For localnet deployments, ensure your local node is running
dubhe publish --network <network> [--config-path <path>] [--named-addresses <addresses>]
 
Options:
  --network           Target network (mainnet/testnet/devnet/local/movementtestnet/movementdevnet/movementlocal)
  --config-path       Config file path (default: "dubhe.config.ts")
  --named-addresses   Named addresses in format "name1=address1,name2=address2"

upgrade

Upgrade deployed Dubhe contracts.

dubhe upgrade --network <network> [--config-path <path>]
 
Options:
  --network        Target network (mainnet/testnet/devnet/local/movementtestnet/movementdevnet/movementlocal)
  --config-path    Path to config file (default: "dubhe.config.ts")

localnode

Manage local Aptos node.

dubhe localnode <action> [options]
 
Actions:
  start     Start local node
  stop      Stop local node
  status    Check node status
  restart   Restart local node
 
Options:
  --background, -b       Run node in background mode
  --force-restart, -f    Clean state and start new chain at genesis

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., publish --network local).

faucet

Request test tokens from the Aptos faucet. The default faucet service automatically gives test tokens to accounts in .env.

dubhe faucet --network <network> [--recipient <address>] [--amount <number>]
 
Options:
  --network     Network to request tokens on (testnet/devnet/local/movementtestnet/movementdevnet/movementlocal)
  --recipient   Optional recipient address (uses PRIVATE_KEY env if not specified)
  --amount      Amount of tokens to request (default: 50000000)

test

Run tests for Dubhe contracts.

dubhe test [--config-path <path>]
 
Options:
  --config-path    Path to config file (default: "dubhe.config.ts")

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
  • Local
  • Movement Testnet
  • Movement Devnet
  • Movement Local

For testnet/devnet/localnet operations, you can get test tokens using the faucet command.