@cfxdevkit/devnode-server
Shared Hono control plane for the local Conflux dev node.
Install
pnpm
pnpm add @cfxdevkit/devnode-serverSub-paths
| Import | Contents |
|---|---|
@cfxdevkit/devnode-server | Core server types, controller, registry, and network state management |
@cfxdevkit/devnode-server/cli | CLI entrypoint and argument parsing utilities |
Usage
Server
import { createDevnodeServerApp } from '@cfxdevkit/devnode-server';
const app = createDevnodeServerApp();
// Start the server (e.g., with Hono's fetch or a custom adapter)
const port = 52000;
const server = Bun.serve({
fetch: app.fetch,
port,
});
console.log(`Devnode server running at http://127.0.0.1:${port}`);The server exposes HTTP endpoints to manage the local Conflux dev node, including:
- Starting, restarting, and wiping the node
- Toggling mining
- Registering and querying deployed contracts
- Accessing network state (e.g., chain IDs, capabilities)
It uses a shared DevnodeServerController to orchestrate node lifecycle operations and a ContractRegistry to track deployed contracts across networks.
CLI
npx @cfxdevkit/devnode-server start
npx @cfxdevkit/devnode-server restart
npx @cfxdevkit/devnode-server wipe
npx @cfxdevkit/devnode-server mineCLI commands accept optional arguments (e.g., --port, --host, --base-url). Run npx @cfxdevkit/devnode-server --help for full usage.
API Reference
See API.md for the full public surface.
Tier
Tier 1 — platform — May import Tier 0 framework packages.
API Reference
.
// Package name constant for runtime identification.
export declare const __packageName: "@cfxdevkit/devnode-server";
// Options for configuring the DevnodeServerApp, combining controller and accounts route options.
export interface DevnodeServerAppOptions extends DevnodeServerControllerOptions, AccountsRoutesOptions {
}
// Context object provided to DevnodeServer extensions during initialization.
export interface DevnodeServerExtensionContext {
}
// Summary of a node profile, containing lightweight metadata.
export interface NodeProfileSummary {
}
// Full state representation of a node profile, including runtime and configuration details.
export interface NodeProfileState {
}
// Options used to configure the NodeProfileService instance.
export interface NodeProfileServiceOptions {
}
// Creates and returns a configured Hono application instance for the devnode server.
export declare function createDevnodeServerApp(options?: DevnodeServerAppOptions): Hono;
// Service responsible for managing node profiles (e.g., creation, persistence, lifecycle).
export declare class NodeProfileService {Usage
import { createDevnodeServerApp } from '@cfxdevkit/devnode-server';
const app = createDevnodeServerApp({
// options...
});./cli
// Default host address for the devnode server when started via CLI.
export declare const DEFAULT_HOST = "127.0.0.1";
// Default port for the devnode server when started via CLI.
export declare const DEFAULT_PORT = 52000;
// Default base URL constructed from DEFAULT_HOST and DEFAULT_PORT.
export declare const DEFAULT_BASE_URL = "http://127.0.0.1:52000";
// Parsed representation of CLI arguments.
export type ParsedArgs = {
}
// Parses raw CLI argument vector into structured options.
export declare function parseArgs(argv: string[]): ParsedArgs;
// Returns a formatted help message for CLI usage.
export declare function printHelp(): string;
// Executes the appropriate CLI command based on parsed arguments.
export declare function executeCliCommand(parsed: Exclude<ParsedArgs, {
}
// Main entry point for CLI execution; handles argument parsing and command dispatch.
export declare function main(argv?: string[]): Promise<void>;Usage
import { main } from '@cfxdevkit/devnode-server/cli';
await main(); // runs CLI with process.argvLast updated on