@cfxdevkit/cli
v2.0.9
Published
Conflux developer CLI: network status + HD key derivation.
Readme
@cfxdevkit/cli
Tiny developer CLI bundled with @cfxdevkit/cdk. Provides three commands:
cfx status— pings each chain and prints head block / epoch + latency.cfx derive— derives dual-space accounts (EVM0x…+ Corecfx[…]:…) from a mnemonic or generates new ones.cfx generate— prints a fresh BIP-39 mnemonic.
Install
pnpm --filter @cfxdevkit/cli build
node repos/cfx-tools/packages/cli/dist/bin.js --helpWhen published, the cfx binary will be on PATH after pnpm i -g @cfxdevkit/cli.
Examples
cfx status
cfx status --chain core-testnet
cfx status --chain 1030 --rpc https://my-private-rpc.example
cfx status --json
cfx derive --generate --count 3 --core-network-id 1
cfx derive --mnemonic "test test test test test test test test test test test junk" --count 5
cfx derive --mnemonic "..." --type mining --core-network-id 2029 --show-private-keys
cfx generateNotes
- The default
--core-network-idis1029(mainnetcfx:…). Use1for testnet (cfxtest:…) and2029for the local devnet (net2029:…). --type miningswitches the BIP-44 account segment from0'to1', matching the convention used by the original@cfxdevkit/cdkPOC for faucet / miner accounts.- Private keys are not printed unless you pass
--show-private-keys.
API Reference
Sub-paths
| Sub-path | Exports |
|----------|---------|
| . | ParsedArgs, parseArgs, DeriveReport, runDerive, GenerateReport, runGenerate, runStatus, StatusReport, run |
.
export { ParsedArgs }
export { parseArgs }
export { DeriveReport }
export { runDerive }
export { GenerateReport }
export { runGenerate }
export { runStatus }
export { StatusReport }
export { run }Usage
import { run } from '@cfxdevkit/cli';
// Run CLI with default behavior (uses process.argv)
await run();
// Run CLI with custom arguments
await run({
command: 'status',
chain: 'core-testnet',
json: true
});Tier
Tier 1 — platform — May import Tier 0 framework packages.
API Reference
See API.md for the full public surface.
API REFERENCE EXCERPT:
@cfxdevkit/cli — Public API
Conflux developer CLI: network status + HD key derivation.
Sub-paths
| Sub-path | Exports |
|----------|---------|
| . | 15 symbols |
.
// Represents the parsed command-line arguments structure.
export { ParsedArgs }
// Parses raw command-line arguments into a structured format.
export { parseArgs }
// Report type returned after successfully deriving an HD wallet key.
export { DeriveReport }
// Options for configuring HD key derivation.
export { RunDeriveOptions }
// Runs HD key derivation, returning a report.
export { runDerive }
// Report type returned after successfully generating a new keypair.
export { GenerateReport }
// Options for configuring key generation.
export { RunGenerateOptions }
// Generates a new keypair, returning a report.
export { runGenerate }
// Options for querying network status.
export { RunStatusOptions }
// Queries the current network status and returns a report.
export { runStatus }
// Report type returned after successfully retrieving network status.
export { StatusReport }
// Main entry point for CLI execution, dispatching to appropriate subcommands.
export { run }Usage
import { run } from '@cfxdevkit/cli';
// Run the CLI with process.argv
await run(process.argv.slice(2));Subcommand Usage Examples
Derive Accounts
import { runDerive, RunDeriveOptions } from '@cfxdevkit/cli';
const options: RunDeriveOptions = {
mnemonic: 'test test test test test test test test test test test junk',
count: 3,
coreNetworkId: 1,
type: 'mining',
showPrivateKeys: true
};
const report = await runDerive(options);
console.log(report.accounts);Generate Mnemonic
import { runGenerate, RunGenerateOptions } from '@cfxdevkit/cli';
const options: RunGenerateOptions = {
// optional: strength in bits (128, 192, or 256)
};
const report = await runGenerate(options);
console.log(report.mnemonic);Check Network Status
import { runStatus, RunStatusOptions } from '@cfxdevkit/cli';
const options: RunStatusOptions = {
chain: 'core-testnet',
json: true
};
const report = await runStatus(options);
console.log(report);