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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@radiustechsystems/ai-agent-adapter-langchain

v1.0.4

Published

LangChain adapter for the Radius AI Agent Toolkit

Downloads

3

Readme

Radius AI Agent Toolkit - LangChain Adapter

This adapter provides integration between the Radius AI Agent Toolkit and LangChain, allowing you to easily add Radius capabilities to AI agents built with LangChain.

This package is part of the Radius AI Agent Toolkit, which provides tools for integrating AI agents with the Radius platform.

Installation

# Install this specific package
npm install @radiustechsystems/ai-agent-adapter-langchain

# Required peer dependencies
npm install @radiustechsystems/ai-agent-core
npm install @langchain/core

Prerequisites

  • Node.js >=20.12.2 <23
  • LangChain installed in your project:
    • npm install @langchain/core @langchain/openai langchain
  • OpenAI API key or other LLM provider credentials
  • Radius wallet setup with a funded account

Usage

import { getOnChainTools } from "@radiustechsystems/ai-agent-adapter-langchain";
import { createRadiusWallet, sendETH } from "@radiustechsystems/ai-agent-wallet";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { ChatOpenAI } from "@langchain/openai";
import * as dotenv from "dotenv";

// Load environment variables
dotenv.config();

// 1. Create a Radius wallet (always validate your environment variables)
const rpcUrl = process.env.RPC_PROVIDER_URL;
const privateKey = process.env.WALLET_PRIVATE_KEY;

if (!rpcUrl || !privateKey) {
  console.warn("WARNING: Missing required environment variables");
  console.warn("RPC_PROVIDER_URL and WALLET_PRIVATE_KEY must be set");
}

const wallet = await createRadiusWallet({
  rpcUrl,
  privateKey
});

// Retrieve the wallet address
const address = await wallet.getAddress();
console.log(`Wallet address: ${address}`);

// 2. Configure the tools for LangChain
const tools = await getOnChainTools({
  wallet,
  plugins: [
    sendETH(), // Enable ETH transfers
  ]
});

console.log(`Configured ${tools.length} tools for LangChain`);
tools.forEach(tool => {
  console.log(` - ${tool.name}: ${tool.description}`);
});

// 3. Create a LangChain agent with the tools
const llm = new ChatOpenAI({ temperature: 0 });
const prompt = ChatPromptTemplate.fromMessages([
  ["system", "You are a helpful AI assistant with blockchain capabilities."],
  ["human", "{input}"]
]);

// Verify we have the components for creating a LangChain agent
if (
  llm && typeof llm.invoke === 'function' &&
  tools && Array.isArray(tools) && tools.length > 0 &&
  prompt && typeof prompt.format === 'function'
) {
  console.log("All components for creating a LangChain agent are valid");
  
  // For production use, you would create an agent executor like this:
  // const executor = await createToolAgentExecutor({
  //   llm,
  //   tools,
  //   prompt
  // });
  //
  // const result = await executor.invoke({
  //   input: "Send 0.01 ETH to 0x1234..."
  // });
  //
  // console.log(result.output);
}

If you want to include ERC20 token support, you would add:

import { erc20, USDC } from "@radiustechsystems/ai-agent-plugin-erc20";

// Then in the plugins array:
const tools = await getOnChainTools({
  wallet,
  plugins: [
    sendETH(), 
    erc20({ tokens: [USDC] }) // Add ERC20 token support
  ]
});

API Reference

getOnChainTools(options)

Creates a collection of tools compatible with LangChain that provides access to configured Radius features.

Parameters:

  • options.wallet (WalletClientBase): A Radius wallet instance
  • options.plugins (Array): Array of plugin instances to enable

Returns:

  • (Array): An array of LangChain-compatible tools that can be used with LangChain agents

Default Tools:

The getOnChainTools function automatically provides the following wallet-related tools:

  • get_address: Get the address of the wallet
  • get_chain: Get the chain of the wallet
  • get_balance: Get the balance of an address
  • sign_message: Sign a message with the wallet
  • simulate_transaction: Simulate a transaction to check if it would succeed
  • resolve_address: Resolve an ENS name to an address
  • get_transaction_status: Check the status of a transaction

Example:

const tools = await getOnChainTools({
  wallet,
  plugins: [
    sendETH(),
    erc20({ tokens: [USDC] })
  ]
});

Integration Examples

For complete examples integrating this adapter with LangChain, see:

Troubleshooting

Error: Missing LangChain Dependencies

If you encounter errors related to missing LangChain dependencies, ensure you have installed all required packages:

npm install @langchain/core @langchain/openai langchain

Error: Cannot Create Agent Executor

The LangChain agent creation API may change between versions. If you encounter errors creating the agent executor:

  1. Check your LangChain version and ensure compatibility
  2. Verify that your tools have the expected structure (name, description, and call method)
  3. Check the LangChain documentation for the latest API patterns

Related Packages

Resources

Contributing

Please see the Contributing Guide for detailed information about contributing to this toolkit.

License

This project is licensed under the MIT License.