docs ⦿ dedot 🧑‍💻
DedotXTelegramGithub
typink ✏️
typink ✏️
  • Welcome to Typink
  • Introducing Typink
  • Getting started
    • Start a new dapp
    • Migrate from existing dapp
    • Supported networks
  • create-typink CLI
  • Hooks & Providers
    • TypinkProvider
    • useTypink
    • useContract
    • useContractQuery
    • useContractTx
    • useDeployer & useDeployerTx
    • useWatchContractEvent
    • useBalance & useBalances
    • usePSP22Balance
  • Utilities
    • formatBalance
    • txToaster
    • dedot/utils
  • HELP & FAQ
    • Tutorials
      • Develop ink! dApp using Typink
  • Telegram
  • Github
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Hooks & Providers

TypinkProvider

TypinkProvider is the global provider for Typink DApps, it managed shared state internally so hooks and child components can access (accounts, signer, wallet connection, Dedot clients, contract deployments ...)

First thing to do is to wrap your application component with TypinkProvider.

import { popTestnet, development } from 'typink'
import { deployments } from './deployments';

// a default caller address when interact with ink! contract if there is no wallet is connected
const DEFAULT_CALLER = '5xxx...' 

const SUPPORTED_NETWORKS = [popTestnet]; // alephZeroTestnet, ...
if (process.env.NODE_ENV === 'development') {
  SUPPORTED_NETWORKS.push(development);
}

<TypinkProvider
  deployments={deployments}
  defaultCaller={DEFAULT_CALLER}
  supportedNetworks={SUPPORTED_NETWORKS}
  defaultNetworkId={popTestnet.id}
  cacheMetadata={true}>
  <MyAppComponent ... />
</TypinkProvider>

const { connectedAccount, signer } = ... // from subconnect or talisman-connect ...

<TypinkProvider
  deployments={deployments}
  defaultCaller={DEFAULT_CALLER}
  supportedNetworks={SUPPORTED_NETWORKS}
  defaultNetworkId={popTestnet.id}
  cacheMetadata={true}
  connectedAccount={connectedAccount}
  signer={signer}
>
  <MyAppComponent ... />
</TypinkProvider>

Props

deployments

ContractDeployment[]

An array of contract deployments

defaultCaller

string

The default Substrate address used as the default caller for making queries when no wallet is connected.

defaultNetworkId

string

The default network to be used. Choose from supported networks, such as popTestnet, astar, etc.

cacheMetadata

boolean

Toggle whether or not to cache network metadata.

supportedNetworks

NetworkInfo[]

signer

Signer

The signer for handling transactions. If using an external wallet connector (e.g., SubConnect, Talisman Connect), pass your signer here.

connectedAccount

InjectedAccount

The currently connected account. If using an external wallet connector, pass the active account here.

wallets

Wallet [ ]

Provided supported wallets

appName

string

The name of your dApp, used to identify your dApp when connecting to wallets

PreviousHooks & ProvidersNextuseTypink

Last updated 3 months ago

Was this helpful?

If you're using an external wallet connector like or , you will need to pass into the TypinkProvider 2 more props: connectedAccount () & signer () so Typink knows which account & signer to interact with the ink! contracts.

An array of for your dApp.

SubConnect
Talisman Connect
InjectedAccouunt
Signer
supported networks