Skip to Content

@cfxdevkit/core


@cfxdevkit/core / EspaceClient

Class: EspaceClient

Defined in: packages/core/src/clients/evm.ts:80

EVM Space (eSpace) Client Implementation Provides unified interface for Ethereum-compatible operations on Conflux eSpace

Extended by

Implements

Constructors

Constructor

new EspaceClient(config): EspaceClient

Defined in: packages/core/src/clients/evm.ts:88

Parameters

config

ClientConfig

Returns

EspaceClient

Properties

address

address: `0x${string}`

Defined in: packages/core/src/clients/evm.ts:86

Implementation of

ChainClient.address


chain

protected readonly chain: Chain

Defined in: packages/core/src/clients/evm.ts:85


chainId

readonly chainId: number

Defined in: packages/core/src/clients/evm.ts:81

Implementation of

ChainClient.chainId


chainType

readonly chainType: "evm"

Defined in: packages/core/src/clients/evm.ts:82

Implementation of

ChainClient.chainType

Methods

callContract()

callContract<T>(address, abi, functionName, args?): Promise<T>

Defined in: packages/core/src/clients/evm.ts:292

Read a contract function (view/pure). Available on the public client — no wallet / private key required.

Type Parameters

T

T = unknown

Parameters

address

string

abi

unknown[]

functionName

string

args?

unknown[] = []

Returns

Promise<T>

Implementation of

ChainClient.callContract


estimateGas()

estimateGas(tx): Promise<bigint>

Defined in: packages/core/src/clients/evm.ts:152

Parameters

tx

BaseTransaction

Returns

Promise<bigint>

Implementation of

ChainClient.estimateGas


formatAmount()

formatAmount(amount): string

Defined in: packages/core/src/clients/evm.ts:398

Parameters

amount

bigint

Returns

string

Implementation of

ChainClient.formatAmount


getBalance()

getBalance(address): Promise<string>

Defined in: packages/core/src/clients/evm.ts:130

Parameters

address

`0x${string}`

Returns

Promise<string>

Implementation of

ChainClient.getBalance


getBalanceRaw()

getBalanceRaw(address): Promise<bigint>

Defined in: packages/core/src/clients/evm.ts:268

Get the raw balance as a bigint (in wei). Use this when you need the exact value for arithmetic.

Parameters

address

`0x${string}`

Returns

Promise<bigint>

Implementation of

ChainClient.getBalanceRaw


getBlockNumber()

getBlockNumber(): Promise<bigint>

Defined in: packages/core/src/clients/evm.ts:116

Returns

Promise<bigint>

Implementation of

ChainClient.getBlockNumber


getChainId()

getChainId(): Promise<number>

Defined in: packages/core/src/clients/evm.ts:229

Get the current chain ID from the network

Returns

Promise<number>

Implementation of

ChainClient.getChainId


getGasPrice()

getGasPrice(): Promise<bigint>

Defined in: packages/core/src/clients/evm.ts:212

Returns

Promise<bigint>

Implementation of

ChainClient.getGasPrice


getTokenBalance()

getTokenBalance(_address, _tokenAddress): Promise<string>

Defined in: packages/core/src/clients/evm.ts:316

Parameters

_address

string

_tokenAddress

string

Returns

Promise<string>

Implementation of

ChainClient.getTokenBalance


isConnected()

isConnected(): Promise<boolean>

Defined in: packages/core/src/clients/evm.ts:246

Check if the client is connected to the network

Returns

Promise<boolean>


isValidAddress()

isValidAddress(address): boolean

Defined in: packages/core/src/clients/evm.ts:394

Parameters

address

string

Returns

boolean

Implementation of

ChainClient.isValidAddress


parseAmount()

parseAmount(amount): bigint

Defined in: packages/core/src/clients/evm.ts:402

Parameters

amount

string

Returns

bigint

Implementation of

ChainClient.parseAmount


sendTransaction()

sendTransaction(_tx): Promise<string>

Defined in: packages/core/src/clients/evm.ts:256

Parameters

_tx

BaseTransaction

Returns

Promise<string>

Implementation of

ChainClient.sendTransaction


waitForTransaction()

waitForTransaction(hash, timeout?): Promise<TransactionReceipt>

Defined in: packages/core/src/clients/evm.ts:175

Wait for a transaction to be confirmed.

Parameters

hash

string

Transaction hash.

timeout?

number

Timeout in milliseconds (default: 30 000).

Returns

Promise<TransactionReceipt>

Implementation of

ChainClient.waitForTransaction


watchBlocks()

watchBlocks(callback): () => void

Defined in: packages/core/src/clients/evm.ts:346

Parameters

callback

EventCallback<BlockEvent>

Returns

(): void

Returns

void

Implementation of

ChainClient.watchBlocks


watchTransaction()

watchTransaction(_hash, _callback): Promise<() => void>

Defined in: packages/core/src/clients/evm.ts:360

Parameters

_hash

string

_callback

(receipt) => void

Returns

Promise<() => void>


watchTransactions()

watchTransactions(_callback): () => void

Defined in: packages/core/src/clients/evm.ts:386

Parameters

_callback

EventCallback<TransactionEvent>

Returns

(): void

Returns

void

Implementation of

ChainClient.watchTransactions