SDK
Providers
Chain

ChainProvider is used for storing information about application chain as well as to provide network change functionality.

Usage

Wrap your application in ChainProvider.

import { ChainProvider } from '@azuro-org/sdk'
import { WagmiConfig, createConfig } from 'wagmi'
import { polygonMumbai, arbitrumGoerli } from 'viem/chains'
 
 
const wagmiConfig = createConfig(config)
 
function Providers(props: { children: React.ReactNode }) {
  const { children } = props
 
  return (
    <WagmiConfig config={wagmiConfig}>
      <ChainProvider initialChainId={polygonMumbai.id}>
        {children}
      </ChainProvider>
    </WagmiConfig>
  )
}
⚠️

The ChainProvider requires access to the Wagmi context.

Get stored context data.

import { useChain } from '@azuro-org/sdk'
 
const { appChain, walletChain, contracts, betToken, isRightNetwork, setAppChainId } = useChain()

Props

{
  children: React.ReactNode
  initialChainId: ChainId // your initial chain id
}
type ChainId =  100 | 137 | 42161 | 80001 | 421613

Return Value

import { type Chain } from 'wagmi'
 
{
  appChain: Omit<Chain, 'id'> & { id: ChainId } // represents chain in whitch your application sends requests and receives data
  contracts: Contracts // contracts data based on appChain
  betToken: BetToken // bet token based on appChain
  walletChain: Chain | undefined // user's wallet chain
  isRightNetwork: boolean // true if appChain equeal to walletChain
  setAppChainId: (chainId: ChainId) => void // function for change appChain
}
type ChainId =  100 | 137 | 42161 | 80001 | 421613
 
type Contracts = {
  lp: {
    address: `0x${string}`
    abi: typeof lpAbi
  }
  prematchCore: {
    address: `0x${string}`
    abi: typeof prematchCoreAbi
  }
  prematchComboCore: {
    address: `0x${string}`
    abi: typeof prematchComboCoreAbi
  }
  proxyFront: {
    address: `0x${string}`
    abi: typeof proxyFrontAbi
  }
}
 
type BetToken = {
  address?: `0x${string}` | undefined
  symbol: string
  decimals: number
}