@cfxdevkit/devnode-core
Lightweight Hono control plane for Conflux devnode — node control, compilation, and mining. No keystore or wallet deps.
Install
pnpm
pnpm add @cfxdevkit/devnode-coreLightweight Hono control plane for the Conflux devnode.
Exposes node lifecycle, compilation, mining, accounts, and network routes with no keystore or wallet dependencies.
When to use this vs @cfxdevkit/devnode-server
| Package | Routes | Use when |
|---|---|---|
devnode-core | health, node/*, compiler/*, mining/*, accounts/*, network/* | CI scripts, automated testing, lightweight tooling |
devnode-server | all of core + keystore/*, contracts/*, deploy/*, session-key/*, bootstrap/* | Full developer environment with key management |
Usage
import { serve } from '@hono/node-server';
import { createDevnodeCoreApp } from '@cfxdevkit/devnode-core';
const app = createDevnodeCoreApp();
serve({ fetch: app.fetch, port: 52000 }, (info) => {
console.log(`devnode-core listening at http://127.0.0.1:${info.port}`);
});Starting via tooling-cli
# Start devnode-server (full stack, with keystore)
cdk devnode start [--port 52000] [--keystore-path .keystore.json]
# Stop
cdk devnode stop
# Status
cdk devnode statusConsumers connect to the running server using @cfxdevkit/client:
import { createConfluxDevkitClient } from '@cfxdevkit/client';
const client = createConfluxDevkitClient({ baseUrl: 'http://127.0.0.1:52000' });
await client.node.start({ config: { mnemonic: '...' } });API Reference
See API.md for the full public surface.
Tier
Tier 1 — platform — May import Tier 0 framework packages.
Sub-paths
| Sub-path | Exports |
|---|---|
. | 39 symbols |
.
// Package name constant for runtime identification.
export declare const __packageName: "@cfxdevkit/devnode-core";
// Options for initializing the DevnodeCoreApp, combining server controller and accounts route options.
export interface DevnodeCoreAppOptions extends DevnodeServerControllerOptions, AccountsRoutesOptions {
}
// Context object passed to DevnodeCore extensions for integration.
export interface DevnodeCoreExtensionContext {
}
// Represents a compiled contract record stored in the registry.
export interface ContractRecord {
name: string;
abi: any[];
bytecode: string;
deploymentAddress?: string;
}
// Filter criteria for querying the list of registered contracts.
export interface ContractListFilter {
name?: string;
deploymentAddress?: string;
}
// Configuration options for initializing the ContractRegistry.
export interface ContractRegistryOptions {
persistPath?: string;
}
// Configuration object for a network, including chain IDs, endpoints, and capabilities.
export interface NetworkConfig {
profile: NetworkProfile;
chainIds: NetworkChainIds;
capabilities?: NetworkCapabilities;
state?: NetworkStateOptions;
}
// Mapping of chain IDs for Core and eSpace networks.
export interface NetworkChainIds {
core?: string;
eSpace?: string;
}
// Set of optional capabilities supported by a network (e.g., debug, tracing).
export interface NetworkCapabilities {
debug?: boolean;
tracing?: boolean;
}
// Profile metadata for a network (e.g., name, description, environment).
export interface NetworkProfile {
name: string;
description?: string;
environment?: 'dev' | 'test' | 'prod';
}
// Options for configuring the runtime state of a network.
export interface NetworkStateOptions {
genesis?: boolean;
autoMine?: boolean;
}
// Options for configuring the accounts HTTP routes.
export interface AccountsRoutesOptions {
defaultAccounts?: number;
defaultBalance?: string;
}
// Options for configuring the Devnode server controller (e.g., node factory, logging).
export interface DevnodeServerControllerOptions {
nodeFactory?: () => Promise<any>;
logLevel?: 'info' | 'warn' | 'error' | 'debug';
}
// Input payload for starting a new devnode instance.
export interface DevnodeStartInput {
config?: {
mnemonic?: string;
accounts?: number;
balance?: string;
};
}
// Input payload for restarting an existing devnode instance.
export interface DevnodeRestartInput {
config?: {
mnemonic?: string;
};
}
// Input payload for wiping (resetting) a devnode instance.
export interface DevnodeWipeInput {
resetAccounts?: boolean;
}
// Input payload for initiating or stopping mining on the devnode.
export interface DevnodeMineInput {
enabled: boolean;
}API Reference
.
// Package name constant for runtime identification.
export declare const __packageName: "@cfxdevkit/devnode-core";
// Options for initializing the DevnodeCoreApp, combining server controller and accounts route options.
export interface DevnodeCoreAppOptions extends DevnodeServerControllerOptions, AccountsRoutesOptions {
}
// Context object passed to DevnodeCore extensions for integration.
export interface DevnodeCoreExtensionContext {
}
// Represents a compiled contract record stored in the registry.
export interface ContractRecord {
}
// Filter criteria for querying the list of registered contracts.
export interface ContractListFilter {
}
// Configuration options for initializing the ContractRegistry.
export interface ContractRegistryOptions {
}
// Configuration object for a network, including chain IDs, endpoints, and capabilities.
export interface NetworkConfig {
}
// Mapping of chain IDs for Core and eSpace networks.
export interface NetworkChainIds {
}
// Set of optional capabilities supported by a network (e.g., debug, tracing).
export interface NetworkCapabilities {
}
// Profile metadata for a network (e.g., name, description, environment).
export interface NetworkProfile {
}
// Options for configuring the runtime state of a network.
export interface NetworkStateOptions {
}
// Options for configuring the accounts HTTP routes.
export interface AccountsRoutesOptions {
}
// Options for configuring the Devnode server controller (e.g., node factory, logging).
export interface DevnodeServerControllerOptions {
}
// Input payload for starting a new devnode instance.
export interface DevnodeStartInput {
}
// Input payload for restarting an existing devnode instance.
export interface DevnodeRestartInput {
}
// Input payload for wiping (resetting) a devnode instance.
export interface DevnodeWipeInput {
}
// Input payload for initiating or stopping mining on the devnode.
export interface DevnodeMineInput {
}
// Current status of the Devnode server (e.g., running, stopped, error).
export interface DevnodeServerStatus {
}
// Creates and configures a Hono application with all DevnodeCore routes and middleware.
export declare function createDevnodeCoreApp(options?: DevnodeCoreAppOptions): Hono;
// Detects whether a given address belongs to the Core or eSpace network.
export declare function detectSpace(address: string): 'core' | 'espace';
// Returns the chain ID for a given contract network and space (Core or eSpace).
export declare function chainIdForContractNetwork(network: ContractNetwork, space: 'core' | 'espace'): number;
// Returns the default network configuration for a given network type (local/testnet/mainnet).
export declare function defaultNetworkConfig(network: Network): NetworkConfig;
// Returns the default chain IDs for Core and eSpace for a given network type.
export declare function defaultNetworkChainIds(network: Network): NetworkChainIds;
// Creates a Hono router with account management routes (e.g., list, unlock, send).
export declare function createAccountsRoutes(controller: DevnodeServerController, options?: AccountsRoutesOptions): Hono;
// Sends funds on the Core network using the provided input.
export declare function sendCoreFunds(input: {
from: string;
to: string;
amount: string;
controller: DevnodeServerController;
}): Promise<string>;
// Sends funds on the eSpace network using the provided input.
export declare function sendEspaceFunds(input: {
from: string;
to: string;
amount: string;
controller: DevnodeServerController;
}): Promise<string>;
// Creates a Hono router with compiler-related routes (e.g., compile, list artifacts).
export declare function createCompilerRoutes(): Hono;
// Creates a Hono router with mining control routes (e.g., start, stop, status).
export declare function createMiningRoutes(controller: DevnodeServerController): Hono;
// Creates a Hono router with network configuration and state routes.
export declare function createNetworkRoutes(state: NetworkState, options?: {
controller?: DevnodeServerController;
}): Hono;
// Network identifiers for contracts: local, testnet, or mainnet.
export type ContractNetwork = 'local' | 'testnet' | 'mainnet';
// Network identifiers for runtime: local, testnet, or mainnet.
export type Network = 'local' | 'testnet' | 'mainnet';
// Mode of the network: local (private) or public (testnet/mainnet).
export type NetworkMode = 'local' | 'public';
// Keys used to persist network configuration, including extended chain ID fields.
export type PersistedNetworkConfigKey = keyof NetworkConfig | 'coreChainId' | 'espaceChainId';
// Type alias for the default Core funds sender implementation.
export type SendFundsImpl = typeof defaultSendCoreFunds;
// Type alias for the default eSpace funds sender implementation.
export type SendEspaceFundsImpl = typeof defaultSendEspaceFunds;
// Factory function type for creating DevNode instances.
export type DevnodeServerNodeFactory = (config?: DevNodeConfig) => DevNode;
// Manages registration, storage, and retrieval of compiled contract artifacts.
export declare class ContractRegistry {
}
// Controls lifecycle and state of the underlying DevNode instance.
export declare class DevnodeServerController {
}
// Tracks and manages the current network state (e.g., config, chain ID, capabilities).
export declare class NetworkState {
}Usage
import { createDevnodeCoreApp } from '@cfxdevkit/devnode-core';
const app = createDevnodeCoreApp({
// configure server controller, accounts, etc.
});
// app now includes routes for accounts, mining, network, and compilation.Last updated on