LangChain toolkit for reliable Web3 execution via KeeperHub
Project description
langchain-keeperhub
Give your LangChain agent the ability to send tokens, call smart contracts, and resolve ENS names — without ever touching a private key.
langchain-keeperhub is a Python SDK that connects LangChain / LangGraph agents to KeeperHub, a Web3 execution service. You provide an API key; KeeperHub handles wallet management and transaction signing inside a secure enclave (Turnkey TEE). Your code never sees the private key.
Originally built for ETHGlobal OpenAgents.
Independent community project by @devendra116. Not affiliated with or endorsed by KeeperHub.
What can it do?
| Capability | How |
|---|---|
| Send tokens (ETH, USDC, any ERC-20) | transfer_funds tool |
| Read/write smart contracts | contract_call tool |
| Conditional execution ("send only if balance > X") | check_and_execute tool |
| Resolve ENS names (vitalik.eth → 0x...) | resolve_ens / reverse_resolve_ens tools |
| Track transaction history | Built-in SQLite store |
| Manage KeeperHub workflows | Optional MCP bridge |
Your agent gets these as LangChain tools. It decides when and how to use them based on the user's request.
Install
pip install langchain-keeperhub
Optional extras:
pip install "langchain-keeperhub[workflows]" # MCP workflow tools
pip install "langchain-keeperhub[ens]" # keccak fallback (if OpenSSL lacks it)
Quick start
1. Get a KeeperHub API key at app.keeperhub.com (starts with kh_).
2. Install dependencies:
pip install langchain-keeperhub langchain langchain-google-genai langgraph python-dotenv
3. Write your agent:
from dotenv import load_dotenv
from langchain.agents import create_agent
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_keeperhub import KeeperHubToolkit
load_dotenv() # reads KEEPERHUB_API_KEY and GOOGLE_API_KEY from .env
toolkit = KeeperHubToolkit() # or pass api_key="kh_..." directly
agent = create_agent(
model=ChatGoogleGenerativeAI(model="gemini-2.5-flash", temperature=0),
tools=toolkit.get_tools(),
)
result = agent.invoke({"messages": [("user", "Send 1 USDC on Base Sepolia to 0x...")]})
print(result["messages"][-1].content)
Any LangChain-compatible model works (OpenAI, Anthropic, etc.) — the examples just happen to use Gemini.
Tools reference
| Tool | What it does |
|---|---|
transfer_funds |
Send native tokens or ERC-20s. Returns an execution_id. |
contract_call |
Read from or write to any verified smart contract. |
check_and_execute |
Read a value, check a condition, then execute only if it passes. |
get_execution_status |
Poll a write's status by execution_id until it completes. |
list_chains |
List all chains KeeperHub supports. |
fetch_contract_abi |
Fetch a contract's ABI by chain and address. |
get_wallet_address |
Get the wallet address tied to your API key. |
resolve_ens |
ENS/Basenames forward lookup (name → address). Uses public RPC, no KeeperHub API. |
reverse_resolve_ens |
ENS/Basenames reverse lookup (address → name). |
list_execution_history |
Query past writes (requires history=True). |
After any write tool (transfer_funds, contract_call, check_and_execute), always call get_execution_status with the returned execution_id to get the final transaction hash.
Safety options
toolkit = KeeperHubToolkit(
api_key="kh_...",
testnet_only=True, # block writes to mainnet chains
allowed_chain_ids={"11155111", "84532"}, # only Sepolia + Base Sepolia
history=True, # log every write to SQLite
)
Use without an LLM
You can also use KeeperHubClient directly for scripting — no agent needed:
import asyncio
from langchain_keeperhub import KeeperHubClient
async def main():
async with KeeperHubClient() as client:
chains = await client.list_chains()
print(chains)
asyncio.run(main())
Environment variables
| Variable | Required | Purpose |
|---|---|---|
KEEPERHUB_API_KEY |
Yes | Your KeeperHub API key (kh_ prefix) from app.keeperhub.com |
GOOGLE_API_KEY |
Only for examples | Needed by langchain-google-genai for Gemini |
Compatibility
- Python 3.10+
- v0.4+ requires
langchain-core1.x. If you're onlangchain-core0.3.x, uselangchain-keeperhub0.3.x.
Development
git clone https://github.com/devendra116/langchain_keeperhub.git
cd langchain_keeperhub
pip install -e ".[dev]"
pytest
Docs
- Getting Started — install, configure, build your first agent
- Architecture — how the SDK works internally
- ENS Integration — ENS and Basenames resolution details
Links
License
MIT — see LICENSE.
Independent community package. Not an official KeeperHub release. Trademarks belong to their owners.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_keeperhub-0.5.1.tar.gz.
File metadata
- Download URL: langchain_keeperhub-0.5.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cd987f4030d65eac3b0e10bfddacd11f014431a089d07a41edb4c44a2634f2c
|
|
| MD5 |
6fca7850e235c7c210f3f2aebbe811a7
|
|
| BLAKE2b-256 |
2d6e80d4d426e8450939292fef0e81854a88e542487162f3e83edc1a8aa41102
|
File details
Details for the file langchain_keeperhub-0.5.1-py3-none-any.whl.
File metadata
- Download URL: langchain_keeperhub-0.5.1-py3-none-any.whl
- Upload date:
- Size: 46.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f85069fe07d48318690c3bc246d0924b067f651ed369605f73120e7734fc28
|
|
| MD5 |
f22df003cb32862bbb23f4160a172cb3
|
|
| BLAKE2b-256 |
7b1ca1634935cbb6df8f271fea59ee60f86d98f1ab5876c975b335df00e2be27
|