useTypink

useTypink Hook

The useTypink hook is the main hook for accessing all Typink functionality in your React components. It provides access to network clients, wallet management, account information, and contract deployments.

Overview

useTypink combines multiple contexts into a single convenient hook, giving you access to:

  • Network connections and Dedot client instances

  • Wallet connections and account management

  • Contract deployment information

  • Transaction signing capabilities

Import & Basic Usage

import { useTypink } from 'typink';

function MyComponent() {
  const {
    // Network & Client
    ready,
    client,
    network,

    // Wallet & Account
    connectedAccount,
    accounts,
    wallets,

    // Contract
    deployments,
  } = useTypink();

  // Your component logic
}

Properties

A. Network & Client Management

Name
Type
Description

ready

boolean

Indicates whether all network clients are connected and ready for blockchain interactions.

client

CompatibleSubstrateApi<ChainApi>?

The primary Dedot client instance for the main network.

network

NetworkInfo

Primary network information (ID, name, RPC providers, token symbol, decimals).

networkConnection

NetworkConnection

Primary network connection details (network ID and provider type).

networks

NetworkInfo[]

All network info objects (primary first, then secondary networks).

networkConnections

NetworkConnection[]

All network connections (primary first, then secondary).

clients

Map<NetworkId, CompatibleSubstrateApi<ChainApi>>

Map of Dedot client instances indexed by network ID for multi-network access.

connectionStatus

Map<NetworkId, ClientConnectionStatus>

Connection status for each network (NotConnected, Connecting, or Connected).

setNetwork

(connection: NetworkId | NetworkConnection) => void

Switch to a different primary network.

setNetworks

(networks: (NetworkId | NetworkConnection)[]) => void

Configure multiple network connections at once (first element becomes primary).

B. Wallet & Account Management

Name
Type
Description

appName

string

Your dApp name as configured in TypinkProvider.

wallets

Wallet[]

All available/configured wallet extensions with their installation and ready status.

connectedWalletIds

string[]

IDs of currently connected wallets.

connectedWallets

Wallet[]

Wallet objects for all currently connected wallets.

accounts

TypinkAccount[]

All accounts from all connected wallets.

connectedAccount

TypinkAccount?

Currently active account used for signing transactions and contract queries.

signer

InjectedSigner?

Signer object for transaction signing (automatically managed by Typink).

connectWallet

(id: string) => Promise<void>

Connect to a wallet by its ID (e.g., 'subwallet-js', 'talisman').

disconnect

(walletId?: string) => void

Disconnect from a specific wallet or all wallets if no ID provided.

setConnectedAccount

(account: TypinkAccount) => void

Switch the currently active account.

C. Contract & Deployment

Name
Type
Description

deployments

ContractDeployment[]

All registered contract deployments with their addresses, metadata, and network info.

defaultCaller

SubstrateAddress

Default address for read-only queries when no wallet is connected.

Last updated

Was this helpful?