npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

core-agentkit-langchain

v0.1.1

Published

LangChain integration for Core AgentKit

Downloads

6

Readme

Core AgentKit LangChain Extension

LangChain integration for Core AgentKit, enabling seamless use of Core blockchain actions within LangChain workflows.

Installation

npm install core-agentkit-langchain

Usage

Method 1: Using LLM with Tools (Recommended)

import {
  AgentKit,
  CoreWalletProvider,
  coreActionProvider,
} from "core-agentkit";
import { getLangChainTools } from "core-agentkit-langchain";
import { ChatOpenAI } from "@langchain/openai";
// or use any other LLM like ChatGoogleGenerativeAI

// Create wallet provider
const walletProvider = new CoreWalletProvider(
  process.env.PRIVATE_KEY!,
  "core-testnet"
);

// Create AgentKit instance
const agentKit = AgentKit.from(walletProvider, [coreActionProvider()]);

// Get LangChain tools
const tools = await getLangChainTools(agentKit);

// Create LLM with tools
const llm = new ChatOpenAI({ model: "gpt-4", temperature: 0 });
const llmWithTools = llm.bindTools(tools);

// Use the LLM with tools
const result = await llmWithTools.invoke([
  {
    role: "user",
    content: "Transfer 0.1 CORE to 0x742d35Cc6634C0532925a3b8D81C3f83C7A84C5e",
  },
]);

// Handle tool calls
if (result && result.tool_calls && result.tool_calls.length > 0) {
  console.log("Executing tools:", result.tool_calls);

  const toolMessages = await Promise.all(
    result.tool_calls.map(async (toolCall: any) => {
      const tool = tools.find((t: any) => t.name === toolCall.name);
      if (!tool) {
        return {
          content: `Tool ${toolCall.name} not found.`,
          tool_call_id: toolCall.id,
        };
      }

      try {
        const output = await tool.invoke(toolCall.args);
        return {
          content: typeof output === "string" ? output : JSON.stringify(output),
          tool_call_id: toolCall.id,
        };
      } catch (error) {
        return {
          content: `Error executing tool ${toolCall.name}: ${(error as Error).message}`,
          tool_call_id: toolCall.id,
        };
      }
    })
  );

  console.log("Tool execution results:", toolMessages);
}

Method 2: Using LangGraph Agents

import {
  AgentKit,
  CoreWalletProvider,
  coreActionProvider,
} from "core-agentkit";
import { getLangChainTools } from "core-agentkit-langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";

// Create wallet provider
const walletProvider = new CoreWalletProvider(
  process.env.PRIVATE_KEY!,
  "core-testnet"
);

// Create AgentKit instance
const agentKit = AgentKit.from(walletProvider, [coreActionProvider()]);

// Get LangChain tools
const tools = await getLangChainTools(agentKit);

// Create agent
const model = new ChatOpenAI({ temperature: 0 });
const agent = createReactAgent({ llm: model, tools });

// Use agent
const result = await agent.invoke({
  messages: [{ role: "user", content: "Check my CORE balance" }],
});

Available Tools

When you convert Core AgentKit actions to LangChain tools, you get access to:

  • get_balance: Get CORE balance for an address
  • transfer: Transfer CORE tokens to another address
  • get_token_balance: Get ERC-20 token balance for an address
  • transfer_token: Transfer ERC-20 tokens to another address
  • stake: Stake CORE tokens with a validator
  • unstake: Unstake CORE tokens from a validator

API Reference

getLangChainTools(agentKit: AgentKit): Promise<StructuredTool[]>

Converts all actions from a Core AgentKit instance into LangChain tools.

createLangChainTool(action: Action): StructuredTool

Converts a single Core AgentKit action into a LangChain tool.

License

MIT