@gibs/bridge-client

Browser-side endpoints, cached viem public clients, token metadata reads and chain logo URLs for a Gibs Finance bridge interface. It has no framework dependency. It sits between @gibs/bridge-sdk (which prices and builds transfers) and an application that renders them.

Install

  • Run npm install @gibs/bridge-client viem.
  • import loads the ECMAScript module build (dist/). require loads the CommonJS build (dist/cjs/).
  • React Native 0.77 or later: Metro's default configuration and the React Native jest preset load every entry point with no extra setup. Add no resolveRequest hook and no transformIgnorePatterns for these packages.
  • It needs no polyfill, not even for URL: React Native 0.77's own URL and URLSearchParams are partial, and no entry point reads them.
  • It needs Node 20 or later, a modern browser, or React Native 0.77 or later under Hermes.
  • viem is a peer dependency. The range is >=2.35.0 <3.
  • Version note: 1.12.0 and older on npm are broken. Use 1.13.0 or later.

Entry points

  • @gibs/bridge-client/client: clientFromChain(chainId), a cached viem public client per chain.
  • @gibs/bridge-client/endpoints: per-chain RPC endpoint lists with storage and subscription.
  • @gibs/bridge-client/networks: the supported viem chains.
  • @gibs/bridge-client/image: chain logo URLs.
  • @gibs/bridge-client/token-metadata: token metadata reads and caching.
  • @gibs/bridge-client/block-polling: how often to ask a chain for its latest block, once per block.
  • @gibs/bridge-client/chain-read: allowance reads.
  • @gibs/bridge-client/cache: the Cache class.

Example

import { clientFromChain } from '@gibs/bridge-client/client'
import { chainLogoUrl } from '@gibs/bridge-client/image'
import { isSupportedEvmChain } from '@gibs/bridge-client/networks'

const pulsechain = 369

if (isSupportedEvmChain(pulsechain)) {
  const client = clientFromChain(pulsechain)
  const blockNumber = await client.getBlockNumber()
  console.log(blockNumber, chainLogoUrl({ chainId: pulsechain, displayPx: 32 }))
}

Rules

  • Check isSupportedEvmChain(chainId) first. clientFromChain throws for a chain outside the supported list.
  • clientFromChain takes a chain id number. It is not the same function as clientFromChain in @gibs/common, which takes a viem chain and a list of URLs.
  • The client reads its URLs from the endpoint table. An empty entry for a chain falls back to the chain defaults. For the five bridge chains those defaults are demoRpcUrlsFor from @gibs/bridge-sdk/chains, which put the shared valve.city vk_demo key first. They are for demos only: set your own endpoints with setEndpoints in production, or pass your own viem clients to the readers.
  • A chain logo can come from gib.show or from Relay's CDN. Use chainLogoUrl. Do not build the URL yourself.
  • This package reads. It never signs or broadcasts.