Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

createPublicClient

Factory that builds a read-only client extended with every query action.

Setup

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
 
const client = createPublicClient({
  chain: testnet,
  transport: createTransport(),
})

createPublicClient returns a PublicClient = Client<undefined, PublicActions>. The signer slot is undefined, so the type system forbids calling any signing action.

Configuration

chainChain. Chain config (id, name, URL, native coin). Use local, devnet, testnet, or mainnet from @left-curve/sdk.

transportTransport. GraphQL transport instance from createTransport(url?, config?).

namestring, optional, default: "Public Client". Free-form label for debugging.

Methods

App

MethodDescription
getAppConfigApp-level config (cached)
getBalanceBalance of one denom for an address
getBalancesPaginated Coins map for an address
getSupplyTotal supply of a single token
getSuppliesPaginated map of token supplies
getCodeFetch a stored Wasm code by hash
getCodesPaginated list of stored codes
getContractInfoContract metadata by address
getContractsInfoPaginated contract metadata
queryWasmRawRaw base64 storage value
queryWasmSmartTyped JSON query against a contract
queryAppGeneric typed query against the app
queryStatusChain id and latest block info
queryTxIndexed transaction by hash
simulateGas-simulate an unsigned tx

Account Factory

MethodDescription
forgotUsernameUsers associated with a key hash
getAccountInfoAccount details for an address
getAccountSeenNoncesMost-recent nonces consumed by account
getAccountStatusCurrent UserStatus for an address
getAllAccountInfoPaginated map of all accounts
getCodeHashCurrent account contract code hash
getNextAccountIndexNext account index for a username
getUserUser by index or name
getUserKeysIndexer-backed list of PublicKey

DEX

MethodDescription
dexStatusWhether the DEX is paused
getOrderDetails of a single active order
getPairParameters of a single base/quote pair
getPairsPaginated list of trading pairs
getPairStats24h stats for one pair
getAllPairStats24h stats for every pair
ordersByUserActive orders for a user
queryCandlesPaginated candles
queryTradesPaginated trades
simulateSwapExactAmountInQuote output for an exact-input swap
simulateSwapExactAmountOutQuote input for an exact-output swap
simulateWithdrawLiquidityCoins returned for burning LP

Perps

MethodDescription
getPerpsUserStatePerpsUserState for a user
getPerpsUserStateExtendedExtended state with PnL/equity/liq flags
getPerpsOrdersByUserActive perps orders for a user
getPerpsLiquidityDepthBid/ask depth buckets for a pair
getPerpsPairParamPerpsPairParam for one pair
getPerpsPairParamsMap of params across pairs
getPerpsParamGlobal perps parameters
getPerpsPairStatsIndexer 24h stats for a perps pair
getAllPerpsPairStatsIndexer 24h stats for every perps pair
getPerpsPairStatePerpsPairState (OI, funding) for a pair
getPerpsStateGlobal runtime state
getPerpsVaultStatePerps vault state
getVaultSnapshotsHistorical vault snapshots
getFeeRateOverridePer-user fee rate override
queryPerpsCandlesPaginated perps candles
queryPerpsEventsPaginated perps events

Oracle

MethodDescription
getPricesPaginated Record<Denom, Price> from oracle

Indexer

MethodDescription
queryBlockBlock (by height or latest)
searchTxsPaginated transaction search
accountSubscriptionAccount creation events
blockSubscriptionNew finalized blocks
candlesSubscriptionLive candles for a pair
eventsSubscriptionFiltered live events
eventsByAddressesSubscriptionLive events for a set of addresses
transferSubscriptionLive transfer events for a username
tradesSubscriptionLive spot trades for a pair
perpsCandlesSubscriptionLive perps candles
perpsTradesSubscriptionLive perps trades
queryAppSubscriptionLive result of a queryApp request
allPairStatsSubscriptionLive 24h stats for all spot pairs
allPerpsPairStatsSubscriptionLive 24h stats for all perps pairs

End-to-end example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createPublicClient({
  chain: testnet,
  transport: createTransport(),
})
 
const status = await client.queryStatus()
 
const address: Address = "0x1234567890abcdef1234567890abcdef12345678"
const balances = await client.getBalances({ address })
 
const pairs = await client.getPairs({ limit: 10 })
 
const unsubscribe = client.blockSubscription({
  next: ({ block }) => console.log("block", block.blockHeight),
})
 
// later
unsubscribe()

Notes

  • The client is a plain object, not a class. Method calls are just property reads followed by function calls.
  • For tree-shakable usage, import each action and pass the client positionally: getBalance(client, {...}).

See also