Overview
The LangChain integration includes:- 10 Core Tools: Cover all major ICP operations
- 4 Specialized Agents: Pre-configured for different use cases
- Natural Language Processing: Convert human language to blockchain operations
- Type Safety: Full TypeScript support with proper validation
Tool Categories
Identity Tools
get-current-identity
Get information about the currently active identity.
Description: “Get information about the currently active identity including principal, account ID, and type”
Parameters: None
Returns: Identity information as JSON string
Example Usage:
create-identity
Create a new identity from seed phrase or generate anonymous identity.
Description: “Create a new identity. Use ‘type: anonymous’ for anonymous identity or ‘type: seed’ with seedPhrase for secp256k1 identity”
Parameters:
type
:'anonymous' | 'seed'
- Type of identity to createkey
:string
- Unique identifier for the identityseedPhrase
(optional):string
- Seed phrase for secp256k1 identity
Token Tools
get-balance
Check ICP balance for current identity or specific account.
Description: “Get ICP balance for the current identity or a specific account”
Parameters:
account
(optional):string
- Account identifier to check
transfer-icp
Transfer ICP tokens to another account.
Description: “Transfer ICP tokens to another account with optional memo”
Parameters:
to
:string
- Recipient account identifieramount
:string
- Amount to transfer (in ICP, e.g., “1.5”)memo
(optional):string
- Transaction memo
icrc1-transfer
Transfer ICRC-1 tokens.
Description: “Transfer ICRC-1 tokens from a specific token canister”
Parameters:
canisterId
:string
- Token canister IDto
:string
- Recipient principalamount
:string
- Amount to transfermemo
(optional):string
- Transaction memo
Canister Tools
create-canister
Create a new canister with specified cycles.
Description: “Create a new canister with specified cycles amount”
Parameters:
cycles
:string
- Initial cycles amount (e.g., “5T” for 5 trillion)
deploy-wasm
Deploy WASM module to a canister.
Description: “Deploy WASM module to an existing canister”
Parameters:
canisterId
:string
- Target canister IDwasmPath
:string
- Path to WASM filemode
(optional):'install' | 'upgrade' | 'reinstall'
- Deployment mode
get-canister-status
Get detailed status information about a canister.
Description: “Get detailed status information about a canister including cycles, memory usage, and controllers”
Parameters:
canisterId
:string
- Canister ID to query
Cycles Tools
get-cycles-balance
Check cycles balance for a canister.
Description: “Get cycles balance and status information for a specific canister”
Parameters:
canisterId
:string
- Canister ID to check
top-up-cycles
Add cycles to a canister.
Description: “Add cycles to a canister to keep it running”
Parameters:
canisterId
:string
- Canister to top upamount
:string
- Cycles amount (e.g., “2T”)
Specialized Agents
Developer Agent
Pre-configured for canister development and deployment workflows. Capabilities:- Canister lifecycle management
- WASM deployment and upgrades
- Cycles monitoring and management
- Development environment setup
DeFi Agent
Specialized for token operations and financial transactions. Capabilities:- ICP and ICRC token transfers
- Balance management
- Multi-token portfolio tracking
- Transaction history analysis
Governance Agent
Focused on NNS governance and voting operations. Capabilities:- Proposal voting
- Neuron management
- Governance participation
- Staking operations
General Agent
All-purpose agent with access to all tools. Capabilities:- Full access to all ICP operations
- Cross-functional workflows
- Complex multi-step operations
- Comprehensive blockchain management
Natural Language Processing
Direct Processing
Process natural language commands directly through the main agent.Multi-Step Workflows
Error Handling and Validation
The LangChain tools include comprehensive error handling:Tool Integration Patterns
Custom Workflows
Batch Operations
Configuration and Customization
OpenAI Configuration
Tool Filtering
Best Practices
1. Clear Commands
2. Error Recovery
3. State Validation
Performance Considerations
- Caching: Agent responses are cached for similar queries
- Batching: Combine related operations in single messages
- Rate Limiting: Respect OpenAI API rate limits
- Network Optimization: Use local network for development/testing
Security Notes
- API Keys: Never expose OpenAI API keys in client-side code
- Validation: All inputs are validated before blockchain operations
- Permissions: Tools respect identity permissions and canister controllers
- Audit Trail: All operations are logged for debugging and audit purposes