Skip to Content
Devkit CLIAPI Reference

Devkit API Reference

The conflux-devkit dashboard is powered by @cfxdevkit/devnode, which exposes a full programmatic API for use in tests and scripts.


ServerManager

import { ServerManager } from '@cfxdevkit/devnode' const node = new ServerManager(config?)

Constructor options

OptionTypeDefaultDescription
portnumber7748Dashboard port
evmPortnumber8545eSpace RPC port
corePortnumber12537Core Space RPC port
accountsnumber10Pre-funded accounts
mnemonicstringrandomGenesis wallet mnemonic
blockTimenumber0Auto-mine interval (0 = manual)

Methods

start()

await node.start(): Promise<void>

Starts the local Conflux node and (optionally) the dashboard.

stop()

await node.stop(): Promise<void>

Stops the node and frees all ports.

getAccounts()

node.getAccounts(): Account[]

Returns the pre-funded genesis accounts with addresses and private keys.

getEndpoint()

node.getEndpoint(): { evm: string; core: string }

Returns the RPC endpoints.

mine(blocks?)

await node.mine(blocks?: number): Promise<void>

Mine blocks blocks instantly (default: 1).

snapshot()

const id = await node.snapshot(): Promise<string>

Take a state snapshot. Returns snapshot ID.

revert(snapshotId)

await node.revert(id: string): Promise<void>

Restore to a previous snapshot.

setBalance(address, value)

await node.setBalance('0xAddr', parseEther('1000')): Promise<void>

Forcibly set the CFX balance of any address.

impersonate(address)

await node.impersonate('0xAddr'): Promise<void>

Allow sending transactions from address without the private key.


REST API (dashboard)

The dashboard exposes a REST API at http://localhost:7748/api:

MethodPathDescription
GET/api/accountsList genesis accounts
GET/api/blocks/latestLatest block info
POST/api/mineMine N blocks
POST/api/snapshotCreate snapshot
POST/api/revert/:idRevert to snapshot
POST/api/compileCompile Solidity source
POST/api/deployDeploy a contract from the bootstrap library
Last updated on