ic-reactor
    Preparing search index...

    Function createCandidAdapter

    • The CandidAdapter class is used to interact with a canister and retrieve its Candid interface definition. It provides methods to fetch the Candid definition either from the canister's metadata or by using a temporary hack method. If both methods fail, it throws an error.

      import { agentManager } from "./agent"

      const candidAdapter = createCandidAdapter({ agentManager })

      const canisterId = "ryjl3-tyaaa-aaaaa-aaaba-cai"

      // Usage example
      try {
      const definition = await candidAdapter.getCandidDefinition(canisterId)
      console.log(definition)
      } catch (error) {
      console.error(error)
      }

      You can use the candidAdapter to fetch the Candid definition and then pass it to the createReactorCore function.

      import { createReactorCore, createCandidAdapter } from "@ic-reactor/core"
      import { agentManager } from "./agent"

      const candidAdapter = createCandidAdapter({ agentManager })

      const canisterId = "ryjl3-tyaaa-aaaaa-aaaba-cai" // NNS ICP Ledger Canister

      // Usage example
      try {
      const { idlFactory } = await candidAdapter.getCandidDefinition(canisterId)
      const { callMethod } = createReactorCore({
      agentManager,
      canisterId,
      idlFactory,
      })

      const name = await callMethod("name")
      console.log(name) // { name: 'Internet Computer' }
      } catch (error) {
      console.error(error)
      }
      
      

      Parameters

      Returns CandidAdapter