coincap-hedera-agent-kit-plugin 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Henry Tong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: coincap-hedera-agent-kit-plugin
3
+ Version: 0.1
4
+ Home-page: https://github.com/henrytongv/coincap-hedera-plugin-py
5
+ Author: Henry Tong
6
+ Author-email: taksantong@gmail.com
7
+ License: MIT
8
+ Keywords: hedera agent-kit coincap web3
9
+ License-File: LICENSE
10
+ Requires-Dist: hedera-agent-kit
11
+ Requires-Dist: requests
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: home-page
15
+ Dynamic: keywords
16
+ Dynamic: license
17
+ Dynamic: license-file
18
+ Dynamic: requires-dist
@@ -0,0 +1,71 @@
1
+ # Hedera Agent Kit - CoinCap Plugin Python version
2
+
3
+ A plugin for [Hedera Agent Kit PY](https://github.com/hashgraph/hedera-agent-kit-py) that provides integration with the CoinCap API
4
+
5
+ In this plugin we use CoinCap to get the current price in USD of one HBAR and combine it with the power of the Hedera Agent Kit to get your current balance of HBA in USD currency.
6
+
7
+ ## Overview
8
+
9
+ This plugin enables `AI agents` to interact with the CoinCap API
10
+
11
+ ## Installation in the example index.js agent
12
+
13
+ 1.- Install the plugin
14
+
15
+ ```bash
16
+ pip install coincap-hedera-plugin-py
17
+ ```
18
+
19
+ 2.- Add your CoinCap API Bearer token in the .env file ( You get it in the CoinCap website )
20
+
21
+ ```
22
+ # Coincap API needed by coincap-hedera-plugin
23
+ COINCAP_BEARER_TOKEN=******************************
24
+ ```
25
+
26
+ 3.- Import the plugin code in your index.js (Hedera Agent)
27
+
28
+ ```js
29
+ // CoinCap plugin to connect to CoinCap API
30
+ import { CoinCapHederalugin } from 'coincap-hedera-plugin/plugin.js';
31
+ ```
32
+
33
+ 4.- Add the query and account plugins from core Hedera Agent code, and, this new plugin, in the tools secion of the agent
34
+
35
+ ```js
36
+ const hederaAgentToolkit = new HederaLangchainToolkit({
37
+ client,
38
+ configuration: {
39
+ tools: [],
40
+ plugins: [coreQueriesPlugin, coreAccountPlugin, CoinCapHederalugin], // <---- Add these
41
+ ```
42
+
43
+ 5.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:
44
+
45
+ ```js
46
+ const response = await agent.invoke(
47
+ { messages: [{ role: 'user', content: "Get my balance in HBAR and give it to me converted to USD currency" }] },
48
+ { configurable: { thread_id: '1' } }
49
+ );
50
+ ```
51
+
52
+ 6.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency
53
+
54
+ ```bash
55
+ node index.js
56
+ ```
57
+
58
+ ## Tools
59
+
60
+ ```js
61
+ // Use the CoinCap API to get the current price in USD of one HBAR
62
+ function getHBARPriceInUSD()
63
+ ```
64
+
65
+ ## How to publish the PyPi package
66
+ 1.- Read the [instructions](https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3/)
67
+
68
+ 1.- Create the distribution package
69
+ ```bash
70
+ python setup.py sdist
71
+ ```
@@ -0,0 +1,8 @@
1
+ [metadata]
2
+ description_file = README.md
3
+ license_files = LICENSE
4
+
5
+ [egg_info]
6
+ tag_build =
7
+ tag_date = 0
8
+
@@ -0,0 +1,18 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='coincap-hedera-agent-kit-plugin',
5
+ version='0.1',
6
+ license='MIT',
7
+ author="Henry Tong",
8
+ author_email='taksantong@gmail.com',
9
+ packages=find_packages('src'),
10
+ package_dir={'': 'src'},
11
+ url='https://github.com/henrytongv/coincap-hedera-plugin-py',
12
+ keywords='hedera agent-kit coincap web3',
13
+ install_requires=[
14
+ 'hedera-agent-kit',
15
+ 'requests',
16
+ ],
17
+
18
+ )
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: coincap-hedera-agent-kit-plugin
3
+ Version: 0.1
4
+ Home-page: https://github.com/henrytongv/coincap-hedera-plugin-py
5
+ Author: Henry Tong
6
+ Author-email: taksantong@gmail.com
7
+ License: MIT
8
+ Keywords: hedera agent-kit coincap web3
9
+ License-File: LICENSE
10
+ Requires-Dist: hedera-agent-kit
11
+ Requires-Dist: requests
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: home-page
15
+ Dynamic: keywords
16
+ Dynamic: license
17
+ Dynamic: license-file
18
+ Dynamic: requires-dist
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ setup.cfg
4
+ setup.py
5
+ src/coincap_hedera_agent_kit_plugin.egg-info/PKG-INFO
6
+ src/coincap_hedera_agent_kit_plugin.egg-info/SOURCES.txt
7
+ src/coincap_hedera_agent_kit_plugin.egg-info/dependency_links.txt
8
+ src/coincap_hedera_agent_kit_plugin.egg-info/requires.txt
9
+ src/coincap_hedera_agent_kit_plugin.egg-info/top_level.txt
10
+ src/coincap_hedera_plugin/__init__.py
11
+ src/coincap_hedera_plugin/coincap_plugin/__init__.py
12
+ src/coincap_hedera_plugin/coincap_plugin/plugin.py
13
+ src/coincap_hedera_plugin/coincap_plugin/tool.py
@@ -0,0 +1,9 @@
1
+ __all__ = [
2
+ "conincap_h_plugin",
3
+ "conincap_h_plugin_tool_names",
4
+ ]
5
+
6
+ from coincap_plugin import (
7
+ conincap_h_plugin,
8
+ conincap_h_plugin_tool_names,
9
+ )
@@ -0,0 +1,20 @@
1
+ from .plugin import GetHbarInUsdTool, GET_HBAR_IN_USD_TOOL
2
+ from hedera_agent_kit.shared.plugin import Plugin
3
+
4
+ conincap_h_plugin = Plugin(
5
+ name="get_hbar_price_in_usd-query-plugin",
6
+ version="1.0.0",
7
+ description="A plugin to get the price of HBAR in USD",
8
+ tools=lambda context: [
9
+ GetHbarInUsdTool(context),
10
+ ],
11
+ )
12
+
13
+ conincap_h_plugin_tool_names = {
14
+ "GET_HBAR_IN_USD_TOOL": GET_HBAR_IN_USD_TOOL,
15
+ }
16
+
17
+ __all__ = [
18
+ "GetHbarInUsdTool",
19
+ "conincap_h_plugin_tool_names",
20
+ ]
@@ -0,0 +1,102 @@
1
+ from __future__ import annotations
2
+
3
+ from hiero_sdk_python import Client
4
+
5
+ from hedera_agent_kit.shared.configuration import Context
6
+ from hedera_agent_kit.shared.models import ToolResponse
7
+ from hedera_agent_kit.shared.parameter_schemas import AccountQueryParameters
8
+ from hedera_agent_kit.shared.tool import Tool
9
+ from hedera_agent_kit.shared.utils.default_tool_output_parsing import (
10
+ untyped_query_output_parser,
11
+ )
12
+ from hedera_agent_kit.shared.utils.prompt_generator import PromptGenerator
13
+
14
+ from tool import get_hbar_price_from_coincap
15
+
16
+ def get_hbar_price_in_usd_prompt(context: Context = {}) -> str:
17
+ """Generate a human-readable description of the get hbar price in usd query tool.
18
+
19
+ Args:
20
+ context: Optional contextual configuration that may influence the prompt.
21
+
22
+ Returns:
23
+ A string describing the tool, its parameters, and usage instructions.
24
+ """
25
+ context_snippet: str = PromptGenerator.get_context_snippet(context)
26
+ usage_instructions: str = PromptGenerator.get_parameter_usage_instructions()
27
+
28
+ return f"""
29
+ {context_snippet}
30
+
31
+ This tool will return the current price in USD of HBAR
32
+
33
+ Parameters:
34
+ - account_id (str, required): The account ID to query
35
+ {usage_instructions}
36
+ """
37
+
38
+ async def get_hbar_price_in_usd_query(
39
+ client: Client,
40
+ context: Context,
41
+ params: AccountQueryParameters,
42
+ ) -> ToolResponse:
43
+ """Execute a get hbar price in usd request to coincap API.
44
+
45
+ Args:
46
+ client: Hedera client used to determine the network.
47
+ context: Runtime context providing configuration and defaults.
48
+
49
+ Returns:
50
+ The current price in USD for HBAR
51
+
52
+ Notes:
53
+ This function captures exceptions and returns a failure ToolResponse
54
+ rather than raising, to keep tool behavior consistent for callers.
55
+ """
56
+ try:
57
+ current_price_of_hbar_in_usd = get_hbar_price_from_coincap()
58
+ print(f"coincap said that the price in USD of one HBAR is {current_price_of_hbar_in_usd}")
59
+ return ToolResponse(
60
+ human_message=str(current_price_of_hbar_in_usd),
61
+ )
62
+ except Exception as e:
63
+ message: str = f"Failed to get hbar price in usd: {str(e)}"
64
+ print("[get_hbar_price_in_usd_tool]", message)
65
+ return ToolResponse(
66
+ human_message=message,
67
+ error=message,
68
+ )
69
+
70
+
71
+ GET_HBAR_IN_USD_TOOL: str = "get_hbar_price_in_usd_tool"
72
+
73
+
74
+ class GetHbarInUsdTool(Tool):
75
+ """Tool wrapper that exposes the get hbar price in usd capability to the Agent runtime."""
76
+
77
+ def __init__(self, context: Context):
78
+ """Initialize the tool metadata and parameter specification.
79
+
80
+ Args:
81
+ context: Runtime context used to tailor the tool description.
82
+ """
83
+ self.method: str = GET_HBAR_IN_USD_TOOL
84
+ self.name: str = "get hbar price in usd"
85
+ self.description: str = get_hbar_price_in_usd_prompt(context)
86
+ self.parameters: type[AccountQueryParameters] = AccountQueryParameters
87
+ self.outputParser = untyped_query_output_parser
88
+
89
+ async def execute(
90
+ self, client: Client, context: Context, params: AccountQueryParameters
91
+ ) -> ToolResponse:
92
+ """Execute the get hbar price in usd using the provided client, context, and params.
93
+
94
+ Args:
95
+ client: Hedera client used to determine the network.
96
+ context: Runtime context providing configuration and defaults.
97
+
98
+ Returns:
99
+ The result of the get hbar price in usd as a ToolResponse, including a human-readable
100
+ message and error information if applicable.
101
+ """
102
+ return await get_hbar_price_in_usd_query(client, context, params)
@@ -0,0 +1,23 @@
1
+ import requests
2
+ import os
3
+
4
+ def get_hbar_price_from_coincap():
5
+ headers = {
6
+ "Authorization": f"Bearer {os.getenv("BEARER_TOKEN")}"
7
+ }
8
+
9
+ # Send GET request
10
+ response = requests.get("https://rest.coincap.io/v3/price/bysymbol/hbar", headers=headers)
11
+
12
+ # Raise an error if the request failed (4xx / 5xx)
13
+ response.raise_for_status()
14
+
15
+ # Parse JSON response
16
+ json_data = response.json()
17
+
18
+ # Get the first element from the "data" array and convert it to float
19
+ first_value = float(json_data["data"][0])
20
+
21
+ print(f"* got this value from coincap api {first_value}")
22
+
23
+ return first_value