mezoAgent 0.1.4__tar.gz → 0.2.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {mezoagent-0.1.4 → mezoagent-0.2.1}/PKG-INFO +2 -2
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezoAgent.egg-info/PKG-INFO +2 -2
- mezoagent-0.2.1/mezo_agent/__init__.py +1 -0
- mezoagent-0.2.1/mezo_agent/transaction.py +105 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/setup.py +2 -2
- mezoagent-0.1.4/mezo_agent/__init__.py +0 -1
- mezoagent-0.1.4/mezo_agent/transaction.py +0 -53
- {mezoagent-0.1.4 → mezoagent-0.2.1}/README.md +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezoAgent.egg-info/SOURCES.txt +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezoAgent.egg-info/dependency_links.txt +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezoAgent.egg-info/requires.txt +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezoAgent.egg-info/top_level.txt +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezo_agent/config.py +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/mezo_agent/parsing.py +0 -0
- {mezoagent-0.1.4 → mezoagent-0.2.1}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: mezoAgent
|
3
|
-
Version: 0.1
|
3
|
+
Version: 0.2.1
|
4
4
|
Summary: A LangChain based tool kit for AI Agents to send BTC and mUSD transactions on Mezo Matsnet.
|
5
5
|
Author: Dreadwulf
|
6
|
-
Author-email:
|
6
|
+
Author-email: dreadwulf@wtf.com
|
7
7
|
Requires-Python: >=3.7
|
8
8
|
Requires-Dist: web3
|
9
9
|
Requires-Dist: langchain
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: mezoAgent
|
3
|
-
Version: 0.1
|
3
|
+
Version: 0.2.1
|
4
4
|
Summary: A LangChain based tool kit for AI Agents to send BTC and mUSD transactions on Mezo Matsnet.
|
5
5
|
Author: Dreadwulf
|
6
|
-
Author-email:
|
6
|
+
Author-email: dreadwulf@wtf.com
|
7
7
|
Requires-Python: >=3.7
|
8
8
|
Requires-Dist: web3
|
9
9
|
Requires-Dist: langchain
|
@@ -0,0 +1 @@
|
|
1
|
+
from .transaction import mezo_agent_transaction_btc, mezo_agent_musd_transaction
|
@@ -0,0 +1,105 @@
|
|
1
|
+
from web3.exceptions import Web3Exception
|
2
|
+
from langchain.tools import tool
|
3
|
+
from .config import web3_instance, sender_address, account, musd_contract
|
4
|
+
from .parsing import extract_transaction_details
|
5
|
+
|
6
|
+
@tool
|
7
|
+
def mezo_agent_transaction_btc(transaction_prompt: str) -> str:
|
8
|
+
"""
|
9
|
+
Sends BTC on Mezo Matsnet. Parses a transaction request and executes the transfer.
|
10
|
+
"""
|
11
|
+
transaction_details = extract_transaction_details(transaction_prompt)
|
12
|
+
|
13
|
+
if isinstance(transaction_details, str): # Handle errors
|
14
|
+
return transaction_details
|
15
|
+
|
16
|
+
amount = float(transaction_details["amount"])
|
17
|
+
currency = transaction_details["currency"].lower()
|
18
|
+
recipient = transaction_details["recipient"]
|
19
|
+
|
20
|
+
if currency != "btc":
|
21
|
+
return "❌ This function only supports BTC transactions."
|
22
|
+
|
23
|
+
# Convert amount to Wei (BTC uses 18 decimals on Mezo Matsnet)
|
24
|
+
amount_wei = web3_instance.to_wei(amount, "ether")
|
25
|
+
|
26
|
+
# Check sender's BTC balance
|
27
|
+
sender_balance = web3_instance.eth.get_balance(sender_address)
|
28
|
+
sender_balance_btc = web3_instance.from_wei(sender_balance, "ether")
|
29
|
+
|
30
|
+
if sender_balance < amount_wei:
|
31
|
+
return f"❌ Insufficient BTC balance! You have {sender_balance_btc} BTC but need {amount} BTC."
|
32
|
+
|
33
|
+
# Fetch nonce and gas price
|
34
|
+
nonce = web3_instance.eth.get_transaction_count(sender_address)
|
35
|
+
gas_price = web3_instance.eth.gas_price
|
36
|
+
gas_limit = web3_instance.eth.estimate_gas({"to": recipient, "value": amount_wei, "from": sender_address})
|
37
|
+
|
38
|
+
tx = {
|
39
|
+
"to": recipient,
|
40
|
+
"value": amount_wei,
|
41
|
+
"gas": gas_limit,
|
42
|
+
"gasPrice": gas_price,
|
43
|
+
"nonce": nonce,
|
44
|
+
"chainId": 31611, # Mezo Testnet Chain ID
|
45
|
+
}
|
46
|
+
|
47
|
+
try:
|
48
|
+
# Sign and send the transaction
|
49
|
+
signed_tx = account.sign_transaction(tx)
|
50
|
+
tx_hash = web3_instance.eth.send_raw_transaction(signed_tx.raw_transaction)
|
51
|
+
return f"✅ BTC Transaction Successful! Hash: {tx_hash.hex()}"
|
52
|
+
except Web3Exception as e:
|
53
|
+
return f"❌ BTC Transaction Failed: {str(e)}"
|
54
|
+
|
55
|
+
@tool
|
56
|
+
def mezo_agent_musd_transaction(transaction_prompt: str) -> str:
|
57
|
+
"""
|
58
|
+
Sends mUSD on Mezo Matsnet. Parses a transaction request and executes the transfer.
|
59
|
+
|
60
|
+
The transaction_prompt should contain details including the amount, the currency
|
61
|
+
(which must be "mUSD"), and the recipient's wallet address.
|
62
|
+
"""
|
63
|
+
transaction_details = extract_transaction_details(transaction_prompt)
|
64
|
+
|
65
|
+
if isinstance(transaction_details, str): # Handle errors during extraction
|
66
|
+
return transaction_details
|
67
|
+
|
68
|
+
amount = float(transaction_details["amount"])
|
69
|
+
currency = transaction_details["currency"].lower()
|
70
|
+
recipient = transaction_details["recipient"]
|
71
|
+
|
72
|
+
if currency != "musd":
|
73
|
+
return "❌ This function only supports mUSD transactions."
|
74
|
+
|
75
|
+
# Convert the mUSD amount to its smallest unit (assumes 18 decimals, similar to ETH)
|
76
|
+
amount_token = web3_instance.to_wei(amount, "ether")
|
77
|
+
|
78
|
+
try:
|
79
|
+
# Fetch nonce and gas price for the sender
|
80
|
+
nonce = web3_instance.eth.get_transaction_count(sender_address)
|
81
|
+
gas_price = web3_instance.eth.gas_price
|
82
|
+
|
83
|
+
# Estimate gas required for the token transfer
|
84
|
+
gas_limit = musd_contract.functions.transfer(recipient, amount_token).estimateGas({
|
85
|
+
'from': sender_address
|
86
|
+
})
|
87
|
+
except Exception as e:
|
88
|
+
return f"❌ Failed to prepare mUSD transaction: {str(e)}"
|
89
|
+
|
90
|
+
# Build the transaction for the token transfer
|
91
|
+
tx = musd_contract.functions.transfer(recipient, amount_token).buildTransaction({
|
92
|
+
'chainId': 31611, # Mezo Testnet Chain ID
|
93
|
+
'from': sender_address,
|
94
|
+
'nonce': nonce,
|
95
|
+
'gas': gas_limit,
|
96
|
+
'gasPrice': gas_price
|
97
|
+
})
|
98
|
+
|
99
|
+
try:
|
100
|
+
# Sign and send the transaction
|
101
|
+
signed_tx = account.sign_transaction(tx)
|
102
|
+
tx_hash = web3_instance.eth.send_raw_transaction(signed_tx.raw_transaction)
|
103
|
+
return f"✅ mUSD Transaction Successful! Hash: {tx_hash.hex()}"
|
104
|
+
except Web3Exception as e:
|
105
|
+
return f"❌ mUSD Transaction Failed: {str(e)}"
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name="mezoAgent",
|
5
|
-
version="0.1
|
5
|
+
version="0.2.1",
|
6
6
|
packages=find_packages(),
|
7
7
|
install_requires=[
|
8
8
|
"web3",
|
@@ -12,6 +12,6 @@ setup(
|
|
12
12
|
],
|
13
13
|
description="A LangChain based tool kit for AI Agents to send BTC and mUSD transactions on Mezo Matsnet.",
|
14
14
|
author="Dreadwulf",
|
15
|
-
author_email="
|
15
|
+
author_email="dreadwulf@wtf.com",
|
16
16
|
python_requires=">=3.7",
|
17
17
|
)
|
@@ -1 +0,0 @@
|
|
1
|
-
from .transaction import mezo_agent_transaction_btc
|
@@ -1,53 +0,0 @@
|
|
1
|
-
from web3.exceptions import Web3Exception
|
2
|
-
from langchain.tools import tool
|
3
|
-
from .config import web3_instance, sender_address, account
|
4
|
-
from .parsing import extract_transaction_details
|
5
|
-
|
6
|
-
@tool
|
7
|
-
def mezo_agent_transaction_btc(transaction_prompt: str) -> str:
|
8
|
-
"""
|
9
|
-
Sends BTC on Mezo Matsnet. Parses a transaction request and executes the transfer.
|
10
|
-
"""
|
11
|
-
transaction_details = extract_transaction_details(transaction_prompt)
|
12
|
-
|
13
|
-
if isinstance(transaction_details, str): # Handle errors
|
14
|
-
return transaction_details
|
15
|
-
|
16
|
-
amount = float(transaction_details["amount"])
|
17
|
-
currency = transaction_details["currency"].lower()
|
18
|
-
recipient = transaction_details["recipient"]
|
19
|
-
|
20
|
-
if currency != "btc":
|
21
|
-
return "❌ This function only supports BTC transactions."
|
22
|
-
|
23
|
-
# Convert amount to Wei (BTC uses 18 decimals on Mezo Matsnet)
|
24
|
-
amount_wei = web3_instance.to_wei(amount, "ether")
|
25
|
-
|
26
|
-
# Check sender's BTC balance
|
27
|
-
sender_balance = web3_instance.eth.get_balance(sender_address)
|
28
|
-
sender_balance_btc = web3_instance.from_wei(sender_balance, "ether")
|
29
|
-
|
30
|
-
if sender_balance < amount_wei:
|
31
|
-
return f"❌ Insufficient BTC balance! You have {sender_balance_btc} BTC but need {amount} BTC."
|
32
|
-
|
33
|
-
# Fetch nonce and gas price
|
34
|
-
nonce = web3_instance.eth.get_transaction_count(sender_address)
|
35
|
-
gas_price = web3_instance.eth.gas_price
|
36
|
-
gas_limit = web3_instance.eth.estimate_gas({"to": recipient, "value": amount_wei, "from": sender_address})
|
37
|
-
|
38
|
-
tx = {
|
39
|
-
"to": recipient,
|
40
|
-
"value": amount_wei,
|
41
|
-
"gas": gas_limit,
|
42
|
-
"gasPrice": gas_price,
|
43
|
-
"nonce": nonce,
|
44
|
-
"chainId": 31611, # Mezo Testnet Chain ID
|
45
|
-
}
|
46
|
-
|
47
|
-
try:
|
48
|
-
# Sign and send the transaction
|
49
|
-
signed_tx = account.sign_transaction(tx)
|
50
|
-
tx_hash = web3_instance.eth.send_raw_transaction(signed_tx.raw_transaction)
|
51
|
-
return f"✅ BTC Transaction Successful! Hash: {tx_hash.hex()}"
|
52
|
-
except Web3Exception as e:
|
53
|
-
return f"❌ BTC Transaction Failed: {str(e)}"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|