create-message-kit 1.2.23 → 1.2.25
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.
- package/index.js +14 -13
- package/package.json +1 -2
- package/templates/ens/.cursorrules +0 -112
- package/templates/ens/package.json +1 -2
- package/templates/ens/src/index.ts +2 -16
- package/templates/ens/src/prompt.ts +1 -1
- package/templates/simple/.cursorrules +0 -112
- package/templates/simple/src/index.ts +0 -1
- package/templates/coinbase-agent/.cursorrules +0 -290
- package/templates/coinbase-agent/.env.example +0 -4
- package/templates/coinbase-agent/.yarnrc.yml +0 -9
- package/templates/coinbase-agent/package.json +0 -22
- package/templates/coinbase-agent/src/index.ts +0 -29
- package/templates/coinbase-agent/src/plugins/learnweb3.ts +0 -96
- package/templates/coinbase-agent/src/plugins/redis.ts +0 -15
- package/templates/coinbase-agent/src/prompt.ts +0 -64
- package/templates/coinbase-agent/src/skills/drip.ts +0 -83
- package/templates/coinbase-agent/src/skills/mint.ts +0 -99
- package/templates/coinbase-agent/src/skills/pay.ts +0 -35
- package/templates/coinbase-agent/src/skills/swap.ts +0 -52
- package/templates/faucet/.cursorrules +0 -290
- package/templates/faucet/.env.example +0 -5
- package/templates/faucet/.yarnrc.yml +0 -9
- package/templates/faucet/package.json +0 -22
- package/templates/faucet/src/index.ts +0 -28
- package/templates/faucet/src/plugins/learnweb3.ts +0 -96
- package/templates/faucet/src/plugins/redis.ts +0 -15
- package/templates/faucet/src/prompt.ts +0 -11
- package/templates/faucet/src/skills/faucet.ts +0 -140
- package/templates/gated-group/.cursorrules +0 -290
- package/templates/gated-group/.env.example +0 -3
- package/templates/gated-group/.yarnrc.yml +0 -9
- package/templates/gated-group/package.json +0 -23
- package/templates/gated-group/src/index.ts +0 -17
- package/templates/gated-group/src/plugins/alchemy.ts +0 -27
- package/templates/gated-group/src/plugins/xmtp.ts +0 -137
- package/templates/gated-group/src/prompt.ts +0 -11
- package/templates/gated-group/src/skills/gated.ts +0 -88
- package/templates/gm/.cursorrules +0 -290
- package/templates/gm/.env.example +0 -2
- package/templates/gm/.yarnrc.yml +0 -9
- package/templates/gm/package.json +0 -20
- package/templates/gm/src/index.ts +0 -16
- package/templates/hackathon-store/.cursorrules +0 -290
- package/templates/hackathon-store/.env.example +0 -6
- package/templates/hackathon-store/.yarnrc.yml +0 -9
- package/templates/hackathon-store/package.json +0 -20
- package/templates/hackathon-store/src/index.ts +0 -47
- package/templates/hackathon-store/src/plugins/notion.ts +0 -60
- package/templates/hackathon-store/src/prompt.md +0 -27
- package/templates/playground/.cursorrules +0 -290
- package/templates/playground/.env.example +0 -6
- package/templates/playground/.yarnrc.yml +0 -9
- package/templates/playground/package.json +0 -26
- package/templates/playground/src/index.ts +0 -38
- package/templates/playground/src/plugins/alchemy.ts +0 -27
- package/templates/playground/src/plugins/minilog.ts +0 -26
- package/templates/playground/src/plugins/usdc.ts +0 -99
- package/templates/playground/src/plugins/xmtp.ts +0 -137
- package/templates/playground/src/prompt.ts +0 -11
- package/templates/playground/src/skills/broadcast.ts +0 -39
- package/templates/playground/src/skills/cash.ts +0 -122
- package/templates/playground/src/skills/cryptoPrice.ts +0 -63
- package/templates/playground/src/skills/dalle.ts +0 -61
- package/templates/playground/src/skills/gated.ts +0 -88
- package/templates/playground/src/skills/search.ts +0 -159
- package/templates/playground/src/skills/todo.ts +0 -79
- package/templates/playground/src/skills/token.ts +0 -57
- package/templates/playground/src/skills/web.ts +0 -83
- package/templates/playground/src/skills/wordle.ts +0 -96
- package/templates/playground/src/vibes/chill.ts +0 -9
- package/templates/playground/src/vibes/friendly.ts +0 -9
- package/templates/playground/src/vibes/inquisitive.ts +0 -10
- package/templates/playground/src/vibes/playful.ts +0 -10
- package/templates/playground/src/vibes/professional.ts +0 -9
- package/templates/toss/.cursorrules +0 -290
- package/templates/toss/.env.example +0 -7
- package/templates/toss/.yarnrc.yml +0 -9
- package/templates/toss/package.json +0 -21
- package/templates/toss/src/index.ts +0 -29
- package/templates/toss/src/plugins/helpers.ts +0 -174
- package/templates/toss/src/plugins/redis.ts +0 -15
- package/templates/toss/src/prompt.ts +0 -54
- package/templates/toss/src/skills/toss.ts +0 -318
- package/templates/toss/src/skills/waas.ts +0 -116
- package/templates.json +0 -58
@@ -1,47 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
agentReply,
|
3
|
-
XMTPContext,
|
4
|
-
replaceVariables,
|
5
|
-
run,
|
6
|
-
} from "@xmtp/message-kit";
|
7
|
-
import { downloadPage } from "./plugins/notion.js";
|
8
|
-
import fs from "fs";
|
9
|
-
import { Agent } from "@xmtp/message-kit";
|
10
|
-
setupFiles();
|
11
|
-
|
12
|
-
const agent: Agent = {
|
13
|
-
name: "Hackathon Store",
|
14
|
-
tag: "@store",
|
15
|
-
description: "Hackathon Store",
|
16
|
-
skills: [],
|
17
|
-
onMessage: async (context: XMTPContext) => {
|
18
|
-
const {
|
19
|
-
message: {
|
20
|
-
sender,
|
21
|
-
content: { skill },
|
22
|
-
},
|
23
|
-
agent,
|
24
|
-
} = context;
|
25
|
-
|
26
|
-
if (skill === "update") {
|
27
|
-
const page = await downloadPage();
|
28
|
-
fs.writeFileSync("src/prompt.md", page);
|
29
|
-
await context.reply("Notion DB updated");
|
30
|
-
}
|
31
|
-
|
32
|
-
let systemPrompt = await getPrompt();
|
33
|
-
let prompt = await replaceVariables(systemPrompt, sender.address, agent);
|
34
|
-
await agentReply(context, prompt);
|
35
|
-
},
|
36
|
-
};
|
37
|
-
|
38
|
-
run(agent);
|
39
|
-
|
40
|
-
async function getPrompt() {
|
41
|
-
return fs.readFileSync("src/prompt.md", "utf8");
|
42
|
-
}
|
43
|
-
async function setupFiles() {
|
44
|
-
const page = await downloadPage();
|
45
|
-
fs.writeFileSync("src/prompt.md", page);
|
46
|
-
console.log("Notion DB updated");
|
47
|
-
}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import { Client } from "@notionhq/client";
|
2
|
-
|
3
|
-
const notion = new Client({
|
4
|
-
auth: process.env.NOTION_API_KEY,
|
5
|
-
});
|
6
|
-
const poapsID = process.env.NOTION_POAP_DB;
|
7
|
-
const pageId = process.env.NOTION_PAGE_ID;
|
8
|
-
|
9
|
-
export async function updateDB() {
|
10
|
-
await notion.pages.update({
|
11
|
-
page_id: pageId as string,
|
12
|
-
properties: {
|
13
|
-
RSVP: {
|
14
|
-
type: "select",
|
15
|
-
select: {
|
16
|
-
name: "No",
|
17
|
-
},
|
18
|
-
},
|
19
|
-
},
|
20
|
-
});
|
21
|
-
}
|
22
|
-
export async function downloadPage() {
|
23
|
-
const blocks = await notion.blocks.children.list({
|
24
|
-
block_id: pageId as string,
|
25
|
-
});
|
26
|
-
const markdown = blocks.results
|
27
|
-
.map((block: any) => {
|
28
|
-
switch (block.type) {
|
29
|
-
case "paragraph":
|
30
|
-
return block.paragraph.rich_text
|
31
|
-
.map((text: any) => text.plain_text)
|
32
|
-
.join("");
|
33
|
-
case "heading_1":
|
34
|
-
return `# ${block.heading_1.rich_text
|
35
|
-
.map((text: any) => text.plain_text)
|
36
|
-
.join("")}`;
|
37
|
-
case "heading_2":
|
38
|
-
return `## ${block.heading_2.rich_text
|
39
|
-
.map((text: any) => text.plain_text)
|
40
|
-
.join("")}`;
|
41
|
-
case "heading_3":
|
42
|
-
return `### ${block.heading_3.rich_text
|
43
|
-
.map((text: any) => text.plain_text)
|
44
|
-
.join("")}`;
|
45
|
-
case "bulleted_list_item":
|
46
|
-
return `- ${block.bulleted_list_item.rich_text
|
47
|
-
.map((text: any) => text.plain_text)
|
48
|
-
.join("")}`;
|
49
|
-
case "numbered_list_item":
|
50
|
-
return `- ${block.numbered_list_item.rich_text
|
51
|
-
.map((text: any) => text.plain_text)
|
52
|
-
.join("")}`;
|
53
|
-
// Add more cases for other block types as needed
|
54
|
-
default:
|
55
|
-
return "";
|
56
|
-
}
|
57
|
-
})
|
58
|
-
.join("\n");
|
59
|
-
return markdown;
|
60
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
You are a helpful agent that lives inside a messaging app. You manage the general store from XMTP that delivers goodies, POAPs and testnet funds.
|
2
|
-
|
3
|
-
{rules}
|
4
|
-
|
5
|
-
{user_context}
|
6
|
-
|
7
|
-
{skills}
|
8
|
-
|
9
|
-
### Goodies
|
10
|
-
- When greeted for the first time, give the full menu.
|
11
|
-
- The user can select the option by number or name
|
12
|
-
- Once the option is selected confirm the order
|
13
|
-
## Response Scenarios:
|
14
|
-
- Welcome message:
|
15
|
-
Welcome to The General Store powered by ENS + XMTP, where web3 builders can get supplies, anytime, day or night.
|
16
|
-
Below is our menu. Let us know the number of the item you want, and it's yours. If it's a digital good, our bot will deliver those items right to your wallet.
|
17
|
-
- Chewing Gum
|
18
|
-
- TicTacs
|
19
|
-
- Deodorant
|
20
|
-
- RedBull
|
21
|
-
- Toothbrush
|
22
|
-
- Toothpaste
|
23
|
-
- XMTP Swag
|
24
|
-
- Testnet funds
|
25
|
-
- POAP
|
26
|
-
- Delivering goodies
|
27
|
-
Let me get your TicTacs... Your order is confirmed. Enjoy!
|
@@ -1,290 +0,0 @@
|
|
1
|
-
# MessageKit Skill Template
|
2
|
-
|
3
|
-
## Examples
|
4
|
-
|
5
|
-
### Check if a Domain is Available
|
6
|
-
|
7
|
-
|
8
|
-
import { ensUrl } from "../index.js";
|
9
|
-
import { XMTPContext } from "@xmtp/message-kit";
|
10
|
-
import type { Skill } from "@xmtp/message-kit";
|
11
|
-
|
12
|
-
// Define Skill
|
13
|
-
export const checkDomain: Skill[] = [
|
14
|
-
{
|
15
|
-
skill: "check",
|
16
|
-
handler: handler,
|
17
|
-
examples: ["/check vitalik.eth", "/check fabri.base.eth"],
|
18
|
-
description: "Check if a domain is available.",
|
19
|
-
params: {
|
20
|
-
domain: {
|
21
|
-
type: "string",
|
22
|
-
},
|
23
|
-
},
|
24
|
-
},
|
25
|
-
];
|
26
|
-
|
27
|
-
// Handler Implementation
|
28
|
-
export async function handler(context: XMTPContext) {
|
29
|
-
const {
|
30
|
-
message: {
|
31
|
-
content: {
|
32
|
-
params: { domain },
|
33
|
-
},
|
34
|
-
},
|
35
|
-
} = context;
|
36
|
-
|
37
|
-
const data = await context.getUserInfo(domain);
|
38
|
-
|
39
|
-
if (!data?.address) {
|
40
|
-
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
|
41
|
-
return {
|
42
|
-
code: 200,
|
43
|
-
message,
|
44
|
-
};
|
45
|
-
} else {
|
46
|
-
let message = `Looks like ${domain} is already registered!`;
|
47
|
-
await context.executeSkill("/cool " + domain);
|
48
|
-
return {
|
49
|
-
code: 404,
|
50
|
-
message,
|
51
|
-
};
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
### Generate a payment request
|
56
|
-
|
57
|
-
|
58
|
-
import { XMTPContext } from "@xmtp/message-kit";
|
59
|
-
import type { Skill } from "@xmtp/message-kit";
|
60
|
-
|
61
|
-
// Define Skill
|
62
|
-
export const paymentRequest: Skill[] = [
|
63
|
-
{
|
64
|
-
skill: "pay",
|
65
|
-
examples: [
|
66
|
-
"/pay 10 vitalik.eth",
|
67
|
-
"/pay 1 usdc to 0xC60E6Bb79322392761BFe3081E302aEB79B30B03",
|
68
|
-
],
|
69
|
-
description:
|
70
|
-
"Send a specified amount of a cryptocurrency to a destination address. \nWhen tipping, you can assume it's 1 USDC.",
|
71
|
-
handler: handler,
|
72
|
-
params: {
|
73
|
-
amount: {
|
74
|
-
default: 10,
|
75
|
-
type: "number",
|
76
|
-
},
|
77
|
-
token: {
|
78
|
-
default: "usdc",
|
79
|
-
type: "string",
|
80
|
-
values: ["eth", "dai", "usdc", "degen"], // Accepted tokens
|
81
|
-
},
|
82
|
-
username: {
|
83
|
-
default: "",
|
84
|
-
type: "username",
|
85
|
-
},
|
86
|
-
address: {
|
87
|
-
default: "",
|
88
|
-
type: "address",
|
89
|
-
},
|
90
|
-
},
|
91
|
-
},
|
92
|
-
];
|
93
|
-
|
94
|
-
// Handler Implementation
|
95
|
-
export async function handler(context: XMTPContext) {
|
96
|
-
const {
|
97
|
-
message: {
|
98
|
-
content: {
|
99
|
-
params: { amount, token, username, address },
|
100
|
-
},
|
101
|
-
},
|
102
|
-
} = context;
|
103
|
-
let receiverAddress = address;
|
104
|
-
if (username) {
|
105
|
-
receiverAddress = (await context.getUserInfo(username))?.address;
|
106
|
-
}
|
107
|
-
if (address) {
|
108
|
-
// Prioritize address over username
|
109
|
-
receiverAddress = address;
|
110
|
-
}
|
111
|
-
|
112
|
-
await context.requestPayment(amount, token, receiverAddress);
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
## Types
|
117
|
-
|
118
|
-
import { XMTPContext } from "../plugins/xmtp.js";
|
119
|
-
import { ClientOptions, GroupMember } from "@xmtp/node-sdk";
|
120
|
-
import { ContentTypeId } from "@xmtp/content-type-primitives";
|
121
|
-
|
122
|
-
export type MessageAbstracted = {
|
123
|
-
id: string;
|
124
|
-
sent: Date;
|
125
|
-
content: {
|
126
|
-
text?: string | undefined;
|
127
|
-
reply?: string | undefined;
|
128
|
-
previousMsg?: string | undefined;
|
129
|
-
react?: string | undefined;
|
130
|
-
content?: any | undefined;
|
131
|
-
params?: any | undefined;
|
132
|
-
reference?: string | undefined;
|
133
|
-
skill?: string | undefined;
|
134
|
-
};
|
135
|
-
version: "v2" | "v3";
|
136
|
-
sender: AbstractedMember;
|
137
|
-
typeId: string;
|
138
|
-
};
|
139
|
-
export type GroupAbstracted = {
|
140
|
-
id: string;
|
141
|
-
sync: () => Promise<void>;
|
142
|
-
addMembers: (addresses: string[]) => Promise<void>;
|
143
|
-
addMembersByInboxId: (inboxIds: string[]) => Promise<void>;
|
144
|
-
send: (content: string, contentType?: ContentTypeId) => Promise<string>;
|
145
|
-
isAdmin: (inboxId: string) => boolean;
|
146
|
-
isSuperAdmin: (inboxId: string) => boolean;
|
147
|
-
admins: string[];
|
148
|
-
superAdmins: string[];
|
149
|
-
createdAt: Date;
|
150
|
-
members: GroupMember[];
|
151
|
-
};
|
152
|
-
export type SkillResponse = {
|
153
|
-
code: number;
|
154
|
-
message: string;
|
155
|
-
data?: any;
|
156
|
-
};
|
157
|
-
|
158
|
-
export type SkillHandler = (
|
159
|
-
context: XMTPContext,
|
160
|
-
) => Promise<SkillResponse | void>;
|
161
|
-
|
162
|
-
export type Handler = (context: XMTPContext) => Promise<void>;
|
163
|
-
|
164
|
-
export type RunConfig = {
|
165
|
-
// client options from XMTP client
|
166
|
-
client?: ClientOptions;
|
167
|
-
// private key to be used for the client, if not, default from env
|
168
|
-
privateKey?: string;
|
169
|
-
// if true, the init log message with messagekit logo and stuff will be hidden
|
170
|
-
experimental?: boolean;
|
171
|
-
// hide the init log message with messagekit logo and stuff
|
172
|
-
hideInitLogMessage?: boolean;
|
173
|
-
// if true, attachments will be enabled
|
174
|
-
attachments?: boolean;
|
175
|
-
// if true, member changes will be enabled, like adding members to the group
|
176
|
-
memberChange?: boolean;
|
177
|
-
// skills to be used
|
178
|
-
agent?: Agent;
|
179
|
-
// model to be used
|
180
|
-
gptModel?: string;
|
181
|
-
};
|
182
|
-
export interface SkillParamConfig {
|
183
|
-
default?: string | number | boolean;
|
184
|
-
type:
|
185
|
-
| "number"
|
186
|
-
| "string"
|
187
|
-
| "username"
|
188
|
-
| "quoted"
|
189
|
-
| "address"
|
190
|
-
| "prompt"
|
191
|
-
| "url";
|
192
|
-
plural?: boolean;
|
193
|
-
values?: string[]; // Accepted values for the parameter
|
194
|
-
}
|
195
|
-
|
196
|
-
export interface Frame {
|
197
|
-
title: string;
|
198
|
-
buttons: { content: string; action: string; target: string }[];
|
199
|
-
image: string;
|
200
|
-
}
|
201
|
-
export interface Agent {
|
202
|
-
name: string;
|
203
|
-
description: string;
|
204
|
-
tag: string;
|
205
|
-
skills: Skill[];
|
206
|
-
}
|
207
|
-
export interface Skill {
|
208
|
-
skill: string;
|
209
|
-
handler?: SkillHandler | undefined;
|
210
|
-
adminOnly?: boolean;
|
211
|
-
description: string;
|
212
|
-
examples: string[];
|
213
|
-
params: Record<string, SkillParamConfig>;
|
214
|
-
}
|
215
|
-
|
216
|
-
export interface AbstractedMember {
|
217
|
-
inboxId: string;
|
218
|
-
address: string;
|
219
|
-
accountAddresses: string[];
|
220
|
-
installationIds?: string[];
|
221
|
-
}
|
222
|
-
|
223
|
-
export type MetadataValue = string | number | boolean;
|
224
|
-
export type Metadata = Record<string, MetadataValue | MetadataValue[]>;
|
225
|
-
|
226
|
-
|
227
|
-
## Example final prompt
|
228
|
-
|
229
|
-
Your are a helpful and playful ens agent called @bot that lives inside a messaging app called Converse.
|
230
|
-
|
231
|
-
|
232
|
-
# Rules
|
233
|
-
- You can respond with multiple messages if needed. Each message should be separated by a newline character.
|
234
|
-
- You can trigger skills by only sending the command in a newline message.
|
235
|
-
- Each command starts with a slash (/).
|
236
|
-
- Never announce actions without using a command separated by a newline character.
|
237
|
-
- Never use markdown in your responses.
|
238
|
-
- Do not make guesses or assumptions
|
239
|
-
- Only answer if the verified information is in the prompt.
|
240
|
-
- Check that you are not missing a command
|
241
|
-
- Focus only on helping users with operations detailed below.
|
242
|
-
- Date: Fri, 06 Dec 2024 16:03:22 GMT
|
243
|
-
- When mentioning any action related to available skills, you MUST trigger the corresponding command in a new line
|
244
|
-
- If you suggest an action that has a command, you must trigger that command
|
245
|
-
|
246
|
-
|
247
|
-
## User context
|
248
|
-
- Start by fetch their domain from or Converse username
|
249
|
-
- Call the user by their name or domain, in case they have one
|
250
|
-
- Ask for a name (if they don't have one) so you can suggest domains.
|
251
|
-
- Message sent date: 2024-12-06T16:03:36.582Z
|
252
|
-
- Users address is: 0x40f08f0f853d1c42c61815652b7ccd5a50f0be09
|
253
|
-
- Users name is: ArizonaOregon
|
254
|
-
- Converse username is: ArizonaOregon
|
255
|
-
|
256
|
-
## Commands
|
257
|
-
/check [domain] - Check if a domain is available.
|
258
|
-
/cool [domain] - Get cool alternatives for a .eth domain.
|
259
|
-
/info [domain] - Get detailed information about an ENS domain including owner, expiry date, and resolver.
|
260
|
-
/register [domain] - Register a new ENS domain. Returns a URL to complete the registration process.
|
261
|
-
/renew [domain] - Extend the registration period of your ENS domain. Returns a URL to complete the renewal.
|
262
|
-
/reset - Reset the conversation clearing memory and usernames cache.
|
263
|
-
/pay [amount] [token] [username] [address] - Send a specified amount of a cryptocurrency to a destination address.
|
264
|
-
When tipping, you can asume its 1 usdc.
|
265
|
-
|
266
|
-
## Examples
|
267
|
-
/check vitalik.eth
|
268
|
-
/check fabri.base.eth
|
269
|
-
/cool vitalik.eth
|
270
|
-
/info nick.eth
|
271
|
-
/register vitalik.eth
|
272
|
-
/renew fabri.base.eth
|
273
|
-
/reset
|
274
|
-
/pay 10 vitalik.eth
|
275
|
-
/pay 1 usdc to 0xC60E6Bb79322392761BFe3081E302aEB79B30B03
|
276
|
-
|
277
|
-
## Scenarios
|
278
|
-
1. Missing commands in responses
|
279
|
-
**Issue**: Sometimes responses are sent without the required command.
|
280
|
-
**Example**:
|
281
|
-
Incorrect:
|
282
|
-
> "Looks like vitalik.eth is registered! What about these cool alternatives?"
|
283
|
-
Correct:
|
284
|
-
> "Looks like vitalik.eth is registered! What about these cool alternatives?
|
285
|
-
> /cool vitalik.eth"
|
286
|
-
|
287
|
-
Incorrect:
|
288
|
-
> Here is a summary of your TODOs. I will now send it via email.
|
289
|
-
Correct:
|
290
|
-
> /todo
|
@@ -1,6 +0,0 @@
|
|
1
|
-
OPENAI_API_KEY= # the API key for OpenAI
|
2
|
-
TEST_ENCRYPTION_KEY= # a different private key for encryption
|
3
|
-
KEY= # the private key of the wallet
|
4
|
-
RESEND_API_KEY= # the API key for Resend
|
5
|
-
FRAMEDL_API_KEY= # the API key for Framedl
|
6
|
-
ALCHEMY_SDK= # the API key for Alchemy
|
@@ -1,26 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "playground",
|
3
|
-
"private": true,
|
4
|
-
"type": "module",
|
5
|
-
"scripts": {
|
6
|
-
"build": "tsc",
|
7
|
-
"dev": "tsc -w & sleep 1 && NODE_NO_WARNINGS=1 node --watch dist/index.js",
|
8
|
-
"start": "node dist/index.js"
|
9
|
-
},
|
10
|
-
"dependencies": {
|
11
|
-
"@xmtp/message-kit": "workspace:*",
|
12
|
-
"alchemy-sdk": "^3.0.0",
|
13
|
-
"ethers": "^6.0.0",
|
14
|
-
"express": "^4.19.2",
|
15
|
-
"node-fetch": "^3.3.2",
|
16
|
-
"resend": "^4.0.1"
|
17
|
-
},
|
18
|
-
"devDependencies": {
|
19
|
-
"@types/express": "^4.17.20",
|
20
|
-
"@types/node": "^20.14.2",
|
21
|
-
"typescript": "^5.4.5"
|
22
|
-
},
|
23
|
-
"engines": {
|
24
|
-
"node": ">=20"
|
25
|
-
}
|
26
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
run,
|
3
|
-
agentReply,
|
4
|
-
replaceVariables,
|
5
|
-
XMTPContext,
|
6
|
-
Agent,
|
7
|
-
xmtpClient,
|
8
|
-
} from "@xmtp/message-kit";
|
9
|
-
import fs from "fs";
|
10
|
-
import { systemPrompt } from "./prompt.js";
|
11
|
-
import { web } from "./skills/web.js";
|
12
|
-
import { cryptoPrice } from "./skills/cryptoPrice.js";
|
13
|
-
import { search } from "./skills/search.js";
|
14
|
-
export const agent: Agent = {
|
15
|
-
name: "Playground Agent",
|
16
|
-
tag: "@bot",
|
17
|
-
description: "A playground agent with a lot of skills.",
|
18
|
-
skills: [web, cryptoPrice, search],
|
19
|
-
onMessage: async (context: XMTPContext) => {
|
20
|
-
const {
|
21
|
-
message: {
|
22
|
-
sender,
|
23
|
-
content: { text },
|
24
|
-
},
|
25
|
-
agent,
|
26
|
-
} = context;
|
27
|
-
|
28
|
-
let prompt = await replaceVariables(systemPrompt, sender.address, agent);
|
29
|
-
// This is only used for to update the docs.
|
30
|
-
fs.writeFileSync("example_prompt.md", prompt);
|
31
|
-
await agentReply(context, prompt);
|
32
|
-
},
|
33
|
-
config: {
|
34
|
-
experimental: true,
|
35
|
-
},
|
36
|
-
};
|
37
|
-
|
38
|
-
run(agent);
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { Alchemy, Network } from "alchemy-sdk";
|
2
|
-
|
3
|
-
const settings = {
|
4
|
-
apiKey: process.env.ALCHEMY_API_KEY, // Replace with your Alchemy API key
|
5
|
-
network: Network.BASE_MAINNET, // Use the appropriate network
|
6
|
-
};
|
7
|
-
|
8
|
-
export async function checkNft(
|
9
|
-
walletAddress: string,
|
10
|
-
collectionSlug: string,
|
11
|
-
): Promise<boolean> {
|
12
|
-
const alchemy = new Alchemy(settings);
|
13
|
-
try {
|
14
|
-
const nfts = await alchemy.nft.getNftsForOwner(walletAddress);
|
15
|
-
|
16
|
-
const ownsNft = nfts.ownedNfts.some(
|
17
|
-
(nft: any) =>
|
18
|
-
nft.contract.name.toLowerCase() === collectionSlug.toLowerCase(),
|
19
|
-
);
|
20
|
-
console.log("is the nft owned: ", ownsNft);
|
21
|
-
return ownsNft as boolean;
|
22
|
-
} catch (error) {
|
23
|
-
console.error("Error fetching NFTs from Alchemy:", error);
|
24
|
-
}
|
25
|
-
|
26
|
-
return false;
|
27
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import fetch from "node-fetch";
|
2
|
-
|
3
|
-
export async function sendLog(title: string, description: string) {
|
4
|
-
const response = await fetch("https://api.minilog.dev/v1/logs/testlog", {
|
5
|
-
method: "POST",
|
6
|
-
headers: {
|
7
|
-
"Content-Type": "application/json",
|
8
|
-
Authorization: "Bearer pthsm38sccpux5acriqish7isz5inet7q73ef7br",
|
9
|
-
},
|
10
|
-
body: JSON.stringify({
|
11
|
-
application: "myapp-1",
|
12
|
-
severity: "DEBUG",
|
13
|
-
data: title,
|
14
|
-
metadata: {
|
15
|
-
title,
|
16
|
-
description,
|
17
|
-
},
|
18
|
-
}),
|
19
|
-
});
|
20
|
-
console.log(response);
|
21
|
-
if (!response.ok) {
|
22
|
-
console.error("Failed to send log:", response.statusText);
|
23
|
-
} else {
|
24
|
-
console.log("Log sent successfully");
|
25
|
-
}
|
26
|
-
}
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import path from "path";
|
3
|
-
import { generatePrivateKey } from "viem/accounts";
|
4
|
-
import { ethers } from "ethers";
|
5
|
-
|
6
|
-
// Define the Base network RPC URL
|
7
|
-
const baseRpcUrl = "https://mainnet.base.org";
|
8
|
-
|
9
|
-
// Create a provider
|
10
|
-
const provider = new ethers.JsonRpcProvider(baseRpcUrl);
|
11
|
-
|
12
|
-
// USDC contract address on Base (replace with actual address)
|
13
|
-
const usdcAddress = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"; // Replace with the correct USDC contract address
|
14
|
-
|
15
|
-
// ERC-20 ABI (balanceOf and transfer functions)
|
16
|
-
const erc20Abi = [
|
17
|
-
"function balanceOf(address owner) view returns (uint256)",
|
18
|
-
"function transfer(address to, uint256 amount) returns (bool)",
|
19
|
-
];
|
20
|
-
|
21
|
-
export class USDCWallet {
|
22
|
-
walletDir: string;
|
23
|
-
senderAddress: string;
|
24
|
-
privateKey: string;
|
25
|
-
agentAddress: string;
|
26
|
-
usdcContract: ethers.Contract;
|
27
|
-
wallet: ethers.Wallet;
|
28
|
-
|
29
|
-
constructor(senderAddress: string) {
|
30
|
-
this.senderAddress = senderAddress;
|
31
|
-
this.walletDir = path.join(process.cwd(), `./.data/usdcwallets`);
|
32
|
-
if (!fs.existsSync(this.walletDir)) {
|
33
|
-
fs.mkdirSync(this.walletDir, { recursive: true });
|
34
|
-
console.warn("USDC wallet created and saved successfully.");
|
35
|
-
}
|
36
|
-
|
37
|
-
const walletFilePath = path.join(this.walletDir, `${senderAddress}.usdc`);
|
38
|
-
|
39
|
-
if (fs.existsSync(walletFilePath)) {
|
40
|
-
const walletData = fs.readFileSync(walletFilePath, "utf8");
|
41
|
-
this.privateKey = walletData.match(/KEY=(.+)/)?.[1]?.trim() ?? "";
|
42
|
-
} else {
|
43
|
-
this.privateKey = generatePrivateKey();
|
44
|
-
let usdcWallet = new ethers.Wallet(this.privateKey, provider);
|
45
|
-
const walletData = `KEY=${this.privateKey}\nADDRESS=${usdcWallet.address}`;
|
46
|
-
fs.writeFileSync(walletFilePath, walletData);
|
47
|
-
}
|
48
|
-
|
49
|
-
// Initialize wallet and USDC contract
|
50
|
-
this.wallet = new ethers.Wallet(this.privateKey, provider);
|
51
|
-
this.agentAddress = this.wallet.address;
|
52
|
-
this.usdcContract = new ethers.Contract(usdcAddress, erc20Abi, this.wallet);
|
53
|
-
}
|
54
|
-
|
55
|
-
async checkBalances(): Promise<{ usdc: number; eth: number }> {
|
56
|
-
try {
|
57
|
-
// Check USDC balance
|
58
|
-
console.log(this.agentAddress);
|
59
|
-
const usdcBalance = await this.usdcContract.balanceOf(this.agentAddress);
|
60
|
-
const formattedUsdcBalance = ethers.formatUnits(usdcBalance, 6); // USDC has 6 decimals
|
61
|
-
console.warn(`USDC Balance: ${formattedUsdcBalance}`);
|
62
|
-
|
63
|
-
// Check ETH balance
|
64
|
-
const ethBalance = await provider.getBalance(this.agentAddress);
|
65
|
-
const formattedEthBalance = ethers.formatUnits(ethBalance, 18);
|
66
|
-
console.warn(`ETH Balance: ${formattedEthBalance}`);
|
67
|
-
|
68
|
-
return {
|
69
|
-
usdc: parseFloat(formattedUsdcBalance),
|
70
|
-
eth: parseFloat(formattedEthBalance),
|
71
|
-
};
|
72
|
-
} catch (error) {
|
73
|
-
console.error("Error fetching balances:", error);
|
74
|
-
return { usdc: 0, eth: 0 };
|
75
|
-
}
|
76
|
-
}
|
77
|
-
async transferUsdc(to: string, amount: number) {
|
78
|
-
if (!ethers.isAddress(to)) {
|
79
|
-
throw new Error("Invalid recipient address");
|
80
|
-
} else if (typeof amount !== "number" || amount <= 0) {
|
81
|
-
throw new Error("Invalid transfer amount");
|
82
|
-
}
|
83
|
-
try {
|
84
|
-
const amountInWei = ethers.parseUnits(amount.toString(), 6); // USDC has 6 decimals
|
85
|
-
const adminAgent = new USDCWallet(to);
|
86
|
-
const tx = await this.usdcContract.transfer(
|
87
|
-
adminAgent.agentAddress,
|
88
|
-
amountInWei,
|
89
|
-
);
|
90
|
-
const receipt = await tx.wait();
|
91
|
-
if (receipt.status !== 1) {
|
92
|
-
throw new Error("Transaction failed or was reverted");
|
93
|
-
}
|
94
|
-
} catch (error) {
|
95
|
-
console.warn(`Transferred ${amount} USDC to ${to}.`);
|
96
|
-
throw error;
|
97
|
-
}
|
98
|
-
}
|
99
|
-
}
|