Skip to content

Commit ba98d61

Browse files
committed
initial commit
1 parent e154215 commit ba98d61

11 files changed

+2206
-2080
lines changed

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"@elizaos/plugin-ton": "workspace:*",
5353
"@elizaos/plugin-sui": "workspace:*",
5454
"@elizaos/plugin-tee": "workspace:*",
55+
"@elizaos/plugin-iq6900": "workspace:*",
5556
"@elizaos/plugin-multiversx": "workspace:*",
5657
"@elizaos/plugin-near": "workspace:*",
5758
"@elizaos/plugin-zksync-era": "workspace:*",

agent/src/index.ts

+62-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { LensAgentClient } from "@elizaos/client-lens";
77
import { SlackClientInterface } from "@elizaos/client-slack";
88
import { TelegramClientInterface } from "@elizaos/client-telegram";
99
import { TwitterClientInterface } from "@elizaos/client-twitter";
10+
1011
import {
1112
AgentRuntime,
1213
CacheManager,
@@ -64,6 +65,7 @@ import { abstractPlugin } from "@elizaos/plugin-abstract";
6465
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
6566
import { webSearchPlugin } from "@elizaos/plugin-web-search";
6667
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
68+
import { elizaCodeinPlugin } from "@elizaos/plugin-iq6900";
6769
import Database from "better-sqlite3";
6870
import fs from "fs";
6971
import path from "path";
@@ -121,6 +123,58 @@ function isAllStrings(arr: unknown[]): boolean {
121123
return Array.isArray(arr) && arr.every((item) => typeof item === "string");
122124
}
123125

126+
export async function loadCharacterFromOnchain(walletAddress:string): Promise<Character[]> {
127+
const jsonResult = await elizaCodeinPlugin.providers[0].get(undefined,undefined);
128+
console.log("JSON 데이터:", jsonResult);
129+
if (jsonResult == "null") return;
130+
const loadedCharacters = [];
131+
try {
132+
const character = JSON.parse(jsonResult);
133+
validateCharacterConfig(character);
134+
135+
// .id isn't really valid
136+
const characterId = character.id || character.name;
137+
const characterPrefix = `CHARACTER.${characterId.toUpperCase().replace(/ /g, "_")}.`;
138+
139+
const characterSettings = Object.entries(process.env)
140+
.filter(([key]) => key.startsWith(characterPrefix))
141+
.reduce((settings, [key, value]) => {
142+
const settingKey = key.slice(characterPrefix.length);
143+
return { ...settings, [settingKey]: value };
144+
}, {});
145+
146+
if (Object.keys(characterSettings).length > 0) {
147+
character.settings = character.settings || {};
148+
character.settings.secrets = {
149+
...characterSettings,
150+
...character.settings.secrets,
151+
};
152+
}
153+
154+
// Handle plugins
155+
if (isAllStrings(character.plugins)) {
156+
elizaLogger.info("Plugins are: ", character.plugins);
157+
const importedPlugins = await Promise.all(
158+
character.plugins.map(async (plugin) => {
159+
const importedPlugin = await import(plugin);
160+
return importedPlugin.default;
161+
})
162+
);
163+
character.plugins = importedPlugins;
164+
}
165+
166+
loadedCharacters.push(character);
167+
elizaLogger.info(
168+
`Successfully loaded character from: ${walletAddress}`
169+
);
170+
} catch (e) {
171+
elizaLogger.error(
172+
`Error parsing character from ${walletAddress}: ${e}`
173+
);
174+
process.exit(1);
175+
}
176+
177+
}
124178
export async function loadCharacters(
125179
charactersArg: string
126180
): Promise<Character[]> {
@@ -545,6 +599,7 @@ export async function createAgent(
545599
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
546600
? evmPlugin
547601
: null,
602+
548603
(getSecret(character, "SOLANA_PUBLIC_KEY") ||
549604
(getSecret(character, "WALLET_PUBLIC_KEY") &&
550605
!getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith(
@@ -609,6 +664,7 @@ export async function createAgent(
609664
getSecret(character, "ECHOCHAMBERS_API_KEY")
610665
? echoChamberPlugin
611666
: null,
667+
612668
].filter(Boolean),
613669
providers: [],
614670
actions: [],
@@ -755,8 +811,13 @@ const startAgents = async () => {
755811
const args = parseArguments();
756812
let charactersArg = args.characters || args.character;
757813
let characters = [defaultCharacter];
814+
let onchainJson = [];
815+
let iqWallet = process.env.IQ_WALLET_ADDRESS;
758816

759-
if (charactersArg) {
817+
if (iqWallet!=null){
818+
onchainJson = await loadCharacterFromOnchain(iqWallet);
819+
}
820+
if (onchainJson.length === 0 && charactersArg) {
760821
characters = await loadCharacters(charactersArg);
761822
}
762823

packages/plugin-iq6900/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts

packages/plugin-iq6900/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Code In Plugin For Eliza
2+
3+
## Description
4+
Through IQ6900's new inscription standard "Code-In", powerful inscription functionality is provided to Eliza.
5+
Engrave Eliza on the blockchain forever.
6+
All your Character JSON files are input onto the blockchain without compression.
7+
Everyone can read your agent from blocks forever.
8+
9+
## inscription
10+
- **Code-in your eliza**: Go to the site and engrave your character file on-chain. https://elizacodein.com/
11+
12+
## Onchain git
13+
- **Commit your update**:
14+
Update your files anytime.
15+
On our site, your files are managed in a format similar to GitHub,
16+
and our plugin automatically loads your latest agent file.
17+
18+
## Let's get started
19+
- **Edit your .env**: write down IQ_WALLET_ADDRESS to your wallet address that you used on website.
20+
To be sure, right after inscription, wait about 5 minutes and just type pmpn start. You are now all set.
21+
22+
23+
You have engraved an eternal record.
24+
Imagine, someone could develop your agent 200 years from now.
25+
26+
Many things will be updated.
27+
28+
Learn more: https://linktr.ee/IQ6900Docs
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/plugin-iq6900/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@elizaos/plugin-iq6900",
3+
"version": "0.1.5-alpha.5",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@elizaos/core": "workspace:*",
9+
"@solana/web3.js": "^1.98.0"
10+
},
11+
12+
"devDependencies": {
13+
"tsup": "8.3.5",
14+
"@types/node": "^20.0.0"
15+
},
16+
"scripts": {
17+
"build": "tsup --format esm --dts",
18+
"dev": "tsup --format esm --dts --watch",
19+
"lint": "eslint --fix --cache ."
20+
}
21+
}

packages/plugin-iq6900/src/index.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Plugin } from "@elizaos/core";
2+
import { onChainJsonProvider } from "./providers/onChainJsonProvider";
3+
4+
export const elizaCodeinPlugin: Plugin = {
5+
name: "eliza-codein",
6+
description: "Plugin that interacts with the on-chain inscription method “Code-In",
7+
actions: [
8+
/* custom actions */
9+
],
10+
providers: [
11+
onChainJsonProvider
12+
],
13+
evaluators: [
14+
/* custom evaluators */
15+
],
16+
services: [],
17+
clients: [],
18+
};
19+
20+
export default elizaCodeinPlugin;

0 commit comments

Comments
 (0)