Avalanche SDK Client
    Preparing search index...

    Function createProposervmApiClient

    • Creates a proposervm API Client with a given transport configured for a Chain.

      The proposervm API Client is an interface to interact with the proposervm API through Avalanche-specific JSON-RPC API methods.

      Type Parameters

      • transport extends Transport
      • chain extends undefined | Chain = undefined
      • accountOrAddress extends undefined | `0x${string}` | Account = undefined
      • rpcSchema extends undefined | RpcSchema = undefined
      • raw extends boolean = false

      Parameters

      Returns {
          extend: <const client extends { [key: string]: unknown }>(
              fn: (client: { extend: ...; getCurrentEpoch: ...; getProposedHeight: ... }) => client,
          ) => { [K in (...) | (...) | (...)]: (...)[(...)] };
          getCurrentEpoch: () => Promise<GetCurrentEpochReturnType>;
          getProposedHeight: () => Promise<GetProposedHeightReturnType>;
      }

      A proposervm API Client. ProposervmApiClient

      • extend: <const client extends { [key: string]: unknown }>(
            fn: (client: { extend: ...; getCurrentEpoch: ...; getProposedHeight: ... }) => client,
        ) => { [K in (...) | (...) | (...)]: (...)[(...)] }
      • getCurrentEpoch: () => Promise<GetCurrentEpochReturnType>

        Returns the current epoch information for the requested chain (C-Chain, P-Chain, X-Chain).

        import { createAvalancheClient} from '@avalanche-sdk/client'
        import { avalanche } from '@avalanche-sdk/client/chains'

        const client = createAvalancheClient({
        chain: avalanche,
        transport: {
        type: "http",
        },
        })

        const cChainEpoch = await client.proposervm.cChain.getCurrentEpoch()
        const pChainEpoch = await client.proposervm.pChain.getCurrentEpoch()
        const xChainEpoch = await client.proposervm.xChain.getCurrentEpoch()
      • getProposedHeight: () => Promise<GetProposedHeightReturnType>

        Returns this node's current proposer VM height for the requested chain (C-Chain, P-Chain, X-Chain).

        import { createAvalancheClient} from '@avalanche-sdk/client'
        import { avalanche } from '@avalanche-sdk/client/chains'

        const client = createAvalancheClient({
        chain: avalanche,
        transport: {
        type: "http",
        },
        })

        const cChainHeight = await client.proposervm.cChain.getProposedHeight()
        const pChainHeight = await client.proposervm.pChain.getProposedHeight()
        const xChainHeight = await client.proposervm.xChain.getProposedHeight()
      import { createProposervmApiClient} from '@avalanche-sdk/client'
      import { avalanche } from '@avalanche-sdk/client/chains'

      const cChainClient = createProposervmApiClient({
      chain: avalanche,
      transport: {
      type: "http",
      },
      clientType: "proposervmCChain",
      })

      // Get proposer VM height for C-Chain
      const cChainHeight = await cChainClient.getProposedHeight()

      const pChainClient = createProposervmApiClient({
      chain: avalanche,
      transport: {
      type: "http",
      },
      clientType: "proposervmPChain",
      })

      // Get proposer VM height for P-Chain
      const pChainHeight = await pChainClient.getProposedHeight()