NodeClient
Midnight.js API Reference v2.0.2
Midnight.js API Reference / @midnight-ntwrk/midnight-js-testing / NodeClient
Class: NodeClient
Client for interacting with a Midnight node's JSON-RPC API
Constructorsβ
Constructorβ
new NodeClient(
nodeURL,logger):NodeClient
Creates a new NodeClient instance
Parametersβ
nodeURLβ
string
URL of the Midnight node
loggerβ
Logger
Logger instance for recording operations
Returnsβ
NodeClient
Propertiesβ
nodeURLβ
readonlynodeURL:string
Methodsβ
contractState()β
contractState(
contractAddress):Promise<null|ContractState>
Fetches the state of a contract
Parametersβ
contractAddressβ
string
Address of the contract
Returnsβ
Promise<null | ContractState>
Contract state or null if not found
health()β
health():
Promise<void|AxiosResponse<any,any>>
Checks the health status of the node. Makes a GET request to the health endpoint of the node.
Returnsβ
Promise<void | AxiosResponse<any, any>>
A promise that resolves to the response of the health check or logs an error if the request fails.
ledgerState()β
ledgerState(
blockHash):Promise<LedgerState>
Fetches the ledger state at a given block
Parametersβ
blockHashβ
string
Hash of the block
Returnsβ
Promise<LedgerState>
Ledger state
ledgerStateBlob()β
ledgerStateBlob(
blockHash):Promise<Uint8Array<ArrayBufferLike>>
Fetches the raw ledger state blob at a given block
Parametersβ
blockHashβ
string
Hash of the block
Returnsβ
Promise<Uint8Array<ArrayBufferLike>>
Raw ledger state data
Throwsβ
If no ledger state is found
ledgerVersion()β
ledgerVersion(
blockHash):Promise<string>
Fetches the ledger version at a given block
Parametersβ
blockHashβ
string
Hash of the block
Returnsβ
Promise<string>
Ledger version
Throwsβ
If no ledger version is found