ICPAgent class is the main entry point for the ICP Agent Kit, providing access to all plugins and LangChain integration.
Constructor
new ICPAgent(config)
Creates a new ICP Agent instance.
Parameters:
config(optional): Configuration objectnetwork:'mainnet' | 'local'- Network to connect to (default: ‘local’)identity:Identity | string- Identity instance or seed phrasehost:string- Custom RPC hostplugins:string[]- Plugins to enable (default: all)openai: OpenAI configuration for natural language processingapiKey:string- OpenAI API keymodel:string- Model to use (default: ‘gpt-4-turbo-preview’)
Properties
identityPlugin
Access to the Identity Plugin for managing identities, seed phrases, and authentication.
Type: IdentityPlugin
tokenPlugin
Access to the Token Plugin for ICP transfers, ICRC-1/ICRC-2 operations, and balance queries.
Type: TokenPlugin
canisterPlugin
Access to the Canister Plugin for lifecycle management, WASM deployment, and method calls.
Type: CanisterPlugin
cyclesPlugin
Access to the Cycles Plugin for cycles management, monitoring, and forecasting.
Type: CyclesPlugin
config
Current agent configuration.
Type: IICPAgentConfig
identity
Current identity being used by the agent.
Type: Identity
Methods
createAgent(type)
Creates a specialized LangChain agent for natural language processing.
Parameters:
type:'developer' | 'defi' | 'governance' | 'general'- Type of specialized agent
ICPSpecializedAgent
Example:
processNaturalLanguage(command)
Process a natural language command directly through the agent.
Parameters:
command:string- Natural language command to execute
Promise<string> - Execution result
Example:
getActor(canisterId, idlFactory)
Create a typed actor for canister interactions.
Parameters:
canisterId:Principal | string- Canister IDidlFactory:IDL.InterfaceFactory- Candid interface factory
ActorSubclass<T> - Typed actor instance
Example:
getPrincipal()
Get the current identity’s principal.
Returns: Principal - Current principal
getIdentity()
Get the current identity instance.
Returns: Identity - Current identity
destroy()
Clean up resources and destroy the agent.
Returns: Promise<void>