Docs · guide · Python
LangChain tool with FlexYield
A tool your agent can call for any JSON-RPC method on any served chain.
Install
pip install langchain requests
Connect and call
import os, requests
from langchain_core.tools import tool
@tool
def rpc_call(chain: str, method: str, params: list) -> dict:
"""JSON-RPC call through FlexYield. chain: eth_mainnet, base_mainnet, arbitrum_one, optimism_mainnet, polygon_pos, solana_mainnet."""
r = requests.post(f"https://flexyield.io/rpc/{chain}",
headers={"Authorization": f"Bearer {os.environ['FLEXYIELD_KEY']}"},
json={"jsonrpc": "2.0", "id": 1, "method": method, "params": params}, timeout=15)
return r.json()
Replace fy_your_api_key with a key from your dashboard (free tier at registration). Chain slugs: eth_mainnet base_mainnet arbitrum_one optimism_mainnet polygon_pos solana_mainnet — each has its own measured page.
Notes
- Agents prefer the MCP server (/docs#agents): the same call is the rpc_call tool, plus toolbox tools and account tools.
All guides: integration guides · methods and limits · docs.