Skip to content

Public Client

A Public Client is interface to the Conflux Core Space JSON-RPC. See the all supported Public Actions for more details.

Import

import { createPublicClient } from "cive";

Usage

import { http, createPublicClient } from 'cive'
import { mainnet } from 'cive/chains'
const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(),
});

Parameters

transport

The Transport of the Public Client.

const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(), 
});

chain(optional)

The Chain of the Public Client.

const publicClient = createPublicClient({
  chain: mainnet, 
  transport: http(),
});

cacheTime(optional)

  • Type number
  • Default 4000

Time (in ms) that cached data will remain memory.

const publicClient = createPublicClient({
  cacheTime: 10_000, 
  chain: mainnet,
  transport: http(),
});

key(optional)

  • Type string
  • Default public

The key of the Public Client.

const publicClient = createPublicClient({
  key: "public", 
  chain: mainnet,
  transport: http(),
});

name(optional)

  • Type string
  • Default Public Client

The name of the Public Client.

const publicClient = createPublicClient({
  name: "Public Client", 
  chain: mainnet,
  transport: http(),
});

pollingInterval(optional)

  • Type number
  • Default 4000
const publicClient = createPublicClient({
  pollingInterval: 4_000, 
  chain: mainnet,
  transport: http(),
});