You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.
Issue Content
This is a continuation of the discussion post #7097 .
We would like to add support for interaction with the Hedera network, including smart contracts, wallet interactions, and access to information through the Mirror Node API. This improvement allows LangChain users to interact with the Hedera network to provide access to verified data, make and record transactions.
We intend to make extensive use of the Hedera REST API, providing features including but not necessarily limited to:
Query Accounts and their balances
List NFTs and Tokens owned by an account
Make and Schedule transactions
Query information from Smart Contracts including execution results and state.
The above could theoretically be equally accomplished with a Document Loader, but the reason for implementation as a Tool is that we also intend to allow agentic behaviour by providing the AI with the ability to interface with the Hedera network:
Prerequisite: The Agent must be provided with a Hedera Account on the same network as defined in baseURL; functioning analogous to an API key, and distinct from the traditional definition of an account as it is closer to a blockchain address/wallet.
Query balance of the provided wallet
Read the Transaction History
Make Transactions
Interact with Smart Contracts (Depending on the implementation of the contract)
i.e. We intend to define a directory for our tool that defines each functionality we implement, with each file defining a subset of functionality relating to either smart contracts, wallets, or the REST API.
Since some of these actions are sensitive, e.g. making transactions, which could cost real money, we intend to implement a permissioning system such that upon initialisation of the tool, its capabilities must be defined by the developer initialising it and providing it to their agent. These permissions will be the following:
An agent provided with a tool with sufficient permissions may then call a given tool like so:
import{initializeAgentExecutorWithOptions}from"langchain/agents";import{OpenAI}from"@langchain/openai";import{HederaQueryBalance,HederaTransactionHistory,HederaSendTransaction,HederaSmartContractQuery,}from"@langchain/community/tools/hedera";import{StructuredTool}from"@langchain/core/tools";exportasyncfunctionrun(){constmodel=newOpenAI({temperature: 0,apiKey: process.env.OPENAI_API_KEY,});// Hedera account credentials and base URL for the networkconsthederaParams={accountId: process.env.HEDERA_ACCOUNT_ID,privateKey: process.env.HEDERA_PRIVATE_KEY,baseURL: "https://testnet.mirrornode.hedera.com",// or mainnet for production};// Initialize the Hedera tools with custom parametersconsttools: StructuredTool[]=[newHederaQueryBalance(hederaParams),newHederaTransactionHistory(hederaParams),newHederaSendTransaction(hederaParams),newHederaSmartContractQuery(hederaParams),];consthederaAgent=awaitinitializeAgentExecutorWithOptions(tools,model,{agentType: "structured-chat-zero-shot-react-description",verbose: true,});constbalanceInput=`Query the balance of my Hedera wallet.`;constbalanceResult=awaithederaAgent.invoke({input: balanceInput});console.log("Balance Result",balanceResult);consttransactionInput=`Fetch the last 5 transactions from my account history.`;consttransactionResult=awaithederaAgent.invoke({input: transactionInput});console.log("Transaction History Result",transactionResult);constsendTransactionInput=`Send 10 HBAR to account 0.0.12345 as a test transaction.`;constsendTransactionResult=awaithederaAgent.invoke({input: sendTransactionInput});console.log("Send Transaction Result",sendTransactionResult);constsmartContractInput=`Query my smart contract for the latest state.`;constsmartContractResult=awaithederaAgent.invoke({input: smartContractInput});console.log("Smart Contract Query Result",smartContractResult);}
If anyone has suggestions, feedback, or tips, we'd greatly appreciate them.
The text was updated successfully, but these errors were encountered:
Privileged issue
Issue Content
This is a continuation of the discussion post #7097 .
We would like to add support for interaction with the Hedera network, including smart contracts, wallet interactions, and access to information through the Mirror Node API. This improvement allows LangChain users to interact with the Hedera network to provide access to verified data, make and record transactions.
We intend to make extensive use of the Hedera REST API, providing features including but not necessarily limited to:
Query Accounts and their balances
List NFTs and Tokens owned by an account
Make and Schedule transactions
Query information from Smart Contracts including execution results and state.
The above could theoretically be equally accomplished with a Document Loader, but the reason for implementation as a Tool is that we also intend to allow agentic behaviour by providing the AI with the ability to interface with the Hedera network:
Prerequisite: The Agent must be provided with a Hedera Account on the same network as defined in baseURL; functioning analogous to an API key, and distinct from the traditional definition of an account as it is closer to a blockchain address/wallet.
Query balance of the provided wallet
Read the Transaction History
Make Transactions
Interact with Smart Contracts (Depending on the implementation of the contract)
Since the tool is multifunctional, we intend to follow a similar general structure to the Gmail tool described in https://js.langchain.com/docs/integrations/tools/gmail/
i.e. We intend to define a directory for our tool that defines each functionality we implement, with each file defining a subset of functionality relating to either smart contracts, wallets, or the REST API.
Since some of these actions are sensitive, e.g. making transactions, which could cost real money, we intend to implement a permissioning system such that upon initialisation of the tool, its capabilities must be defined by the developer initialising it and providing it to their agent. These permissions will be the following:
-> REST API permissions
-> Smart Contract Query permissions
-> Smart Contract Create/Update permissions
-> Wallet Read Permissions (Query Balance, etc.)
-> Wallet Write Permissions (Posting Transactions, etc.)
An agent provided with a tool with sufficient permissions may then call a given tool like so:
If anyone has suggestions, feedback, or tips, we'd greatly appreciate them.
The text was updated successfully, but these errors were encountered: