@agentix/plugin-solana-messari
Version:
154 lines (148 loc) • 5.65 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
default: () => index_default
});
module.exports = __toCommonJS(index_exports);
var import_agentix = require("agentix");
// src/actions/askMessariAi.ts
var import_zod = require("zod");
// src/tools/ask_messari_ai.ts
async function askMessariAi(agent, question) {
try {
const apiKey = agent.config?.MESSARI_API_KEY;
if (!apiKey) {
throw new Error("No Messari API Key provided");
}
const url = `https://api.messari.io/ai/v1/chat/completions`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-messari-api-key": apiKey
},
body: JSON.stringify({
messages: [
{
role: "user",
content: question
}
]
})
});
const data = await response.json();
const result = data.data.messages[0].content;
return result;
} catch (error) {
const errorMessage = error?.errorResponse?.error || error?.message || "Unknown error occurred";
console.error("Error retrieving assets: ", errorMessage);
throw new Error(`Error fetching data from Messari: ${errorMessage}`);
}
}
// src/actions/askMessariAi.ts
var getMessariAiAction = {
name: "GET_MESSARI_AI",
description: `This tool queries Messari AI for comprehensive crypto research across these datasets:
Latest crypto news, CEX/DEX volumes, market share, transaction fees, total transactions, Asset prices,
trading volume, market cap, TVL, and historical performance, Investment data, Technical analysis of how protocols work,
tokenomics, and yield mechanisms, Twitter followers and Reddit subscribers metrics, growth trends`,
similes: [
"Using Messari: What is the average TPS and total fee revenue last month for Solana? ",
"What does Messari say about Solana\u2019s price and volume over the past month?",
"Can you check Solana\u2019s TPS and fee stats last month using Messari?",
"Any recent insights from Messari on Avalanche\u2019s activity?",
"What\u2019s Messari saying about Ethereum staking trends lately?",
"Can you use Messari to see how Uniswap has been performing recently?",
"Find out what Messari reports about NFT trading volume this week.",
"Check with Messari: how\u2019s the Polygon ecosystem been doing?",
"What does Messari say about stablecoin inflows to BSC recently?",
"Can you look up the top DeFi protocols this month on Messari?",
"Any updates from Messari on gas fees for Base or zkSync?",
"What does Messari show about daily users on Arbitrum and Optimism?",
"Is there any data from Messari on token unlocks last week?",
"Check Messari for Bitcoin\u2019s market behavior after the Fed news.",
"Does Messari say anything about Cardano\u2019s developer activity?",
"What are the biggest altcoin gainers recently, according to Messari?",
"Can you use Messari to compare activity between Solana and Ethereum?",
"What does Messari report about recent DAO treasury changes?",
"Any interesting trends in Layer 2 growth according to Messari?"
],
examples: [
[
{
explanation: "This example shows how to ask Messari AI about Solana's TPS and fee revenue.",
input: {
question: "How did ethereum performed over the last month in terms of its price and trading volume?"
},
output: {
data: {
messages: [
{
role: "assistant",
content: "Ethereum (ETH) has shown strong performance over the past month with a 15% price increase. The current price is approximately $3,500, up from $3,000 at the beginning of the month. Trading volume has also increased by 20% in the same period."
}
]
}
}
}
]
],
schema: import_zod.z.object({
question: import_zod.z.string().nonempty()
}),
handler: async (agent, input) => {
try {
const question = input.question;
return {
status: "success",
result: await askMessariAi(agent, question)
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error is not a property of unknown
message: e.message
};
}
}
};
var askMessariAi_default = getMessariAiAction;
// src/index.ts
var MessariPlugin = class extends import_agentix.PluginBase {
constructor() {
const methods = {
askMessariAi
};
const actions = [
askMessariAi_default
];
const supportedChains = [
{
type: "solana"
}
];
super("messari", methods, actions, supportedChains);
}
supportsWallet(wallet) {
return wallet instanceof import_agentix.SolanaWalletBase;
}
};
var index_default = MessariPlugin;