Agent manager handles the lifecycle of the @dfinity/agent. It is responsible for creating agent and managing the agent's state. You can use it to subscribe to the agent changes. login and logout to the internet identity.
@dfinity/agent
import { createAgentManager } from "@ic-reactor/core"export const agentManager = createAgentManager() // Connects to IC network by default Copy
import { createAgentManager } from "@ic-reactor/core"export const agentManager = createAgentManager() // Connects to IC network by default
Local Agent Example:
For development purposes, you might want to connect to a local instance of the IC network:
// agent.tsimport { createAgentManager } from "@ic-reactor/core"export const agentManager = createAgentManager({ withLocalEnv: true, port: 8000, // Default port is 4943}) Copy
// agent.tsimport { createAgentManager } from "@ic-reactor/core"export const agentManager = createAgentManager({ withLocalEnv: true, port: 8000, // Default port is 4943})
Alternatively, you can specify a host directly:
// agent.tsimport { createAgentManager } from "@ic-reactor/core"export const agentManager = createAgentManager({ host: "http://localhost:8000",}) Copy
// agent.tsimport { createAgentManager } from "@ic-reactor/core"export const agentManager = createAgentManager({ host: "http://localhost:8000",})
Copy
Optional
Agent manager handles the lifecycle of the
@dfinity/agent
. It is responsible for creating agent and managing the agent's state. You can use it to subscribe to the agent changes. login and logout to the internet identity.Example
Local Agent Example:
For development purposes, you might want to connect to a local instance of the IC network:
Alternatively, you can specify a host directly: