Snak - Starknet驱动的AI代理工具

@KasarLabs/snak
0 Stars 26 次浏览 KasarLabs 更新于 2026-08-23

构建由Starknet驱动的强大且安全的AI代理。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "nxp_server_example": {
      "args": [
        "-y",
        "@npm_package_example/npx_server_example"
      ],
      "command": "npx",
      "env": {
        "API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

该服务需要配置环境变量:AI_MODEL、AI_PROVIDER、AI_PROVIDER_API_KEY、DISCORD_BOT_TOKEN、DISCORD_CHANNEL_ID、SERVER_API_KEY、SERVER_PORT、STARKNET_PRIVATE_KEY、STARKNET_PUBLIC_ADDRESS、STARKNET_RPC_URL

服务介绍

一个用于创建可以与Starknet区块链交互的AI代理的工具包。既可作为NPM包使用,也可作为一个带有Web界面的即用型NestJS服务器。支持包括Anthropic、OpenAI、Google Gemini和Ollama在内的多个AI提供商。

快速开始

前提条件

  • Starknet钱包(推荐:Argent X
  • AI提供商API密钥(Anthropic/OpenAI/Google Gemini/Ollama)
  • 安装了Node.js和pnpm

安装

git clone https://github.com/kasarlabs/snak.git
cd snak
pnpm install

配置

  1. 创建.env文件:
# Starknet configuration (mandatory)
STARKNET_PUBLIC_ADDRESS="YOUR_STARKNET_PUBLIC_ADDRESS"
STARKNET_PRIVATE_KEY="YOUR_STARKNET_PRIVATE_KEY"
STARKNET_RPC_URL="YOUR_STARKNET_RPC_URL"

# AI Provider configuration (mandatory)
AI_PROVIDER_API_KEY="YOUR_AI_PROVIDER_API_KEY"
AI_MODEL="YOUR_AI_MODEL"
AI_PROVIDER="YOUR_AI_PROVIDER"

# NestJS server configuration
SERVER_API_KEY="YOUR_SERVER_API_KEY"
SERVER_PORT="YOUR_SERVER_PORT"

#Node Configuration # optional by default : production
NODE_ENV="YOUR_NODE_ENV"
# Agent additional configuration

POSTGRES_USER="YOUR_POSTGRES_USER"
POSTGRES_PASSWORD="YOUR_POSTGRES_PASSWORD"
POSTGRES_ROOT_DB="YOUR_POSTGRES_ROOT_DB"
POSTGRES_HOST="YOUR_POSTGRES_HOST"
POSTGRES_PORT="YOUR_POSTGRES_PORT"
  1. 创建你的agent.config.json
{
  "name": "Your Agent name",
  "bio": "Your AI Agent Bio",
  "lore": ["Some lore of your AI Agent 1", "Some lore of your AI Agent 1"],
  "objectives": [
    "first objective that your AI Agent need to follow",
    "second objective that your AI Agent need to follow"
  ],
  "knowledge": [
    "first knowledge of your AI Agent",
    "second knowledge of your AI Agent"
  ],
  "interval": "Your agent interval beetween each transaction of the Agent in ms,",
  "chat_id": "Your Agent Chat-id for isolating memory",
  "autonomous": "Your agent is autonomous or not",
  "plugins": ["Your first plugin", "Your second plugin"],
  "mcpServers": {
    "nxp_server_example": {
      "command": "npx",
      "args": ["-y", "@npm_package_example/npx_server_example"],
      "env": {
        "API_KEY": "YOUR_API_KEY"
      }
    },
    "local_server_example": {
      "command": "node",
      "args": ["node /path/to/local_server/dist/index.js"]
    }
  }
}

你可以简单地通过我们的工具在snakagent上创建自己的代理配置。

使用

提示模式

运行提示:

# start with the default.agent.json
pnpm run start

# start with your custom configuration
pnpm run start --agent="name_of_your_config.json"

服务器模式

运行服务器:

# start with the default.agent.json
pnpm run start:server

# start with your custom configuration
pnpm run start:server --agent="name_of_your_config.json"

可用模式

交互模式 自主模式
提示模式
服务器模式

在你的项目中实现Snak

  1. 安装snak包
#using npm
npm install @starknet-agent-kit

# using pnpm
pnpm add @starknet-agent-kit
  1. 创建你的代理实例
import { StarknetAgent } from 'starknet-agent-kit';

const agent = new StarknetAgent({
  provider: new RpcProvider({ nodeUrl: process.env.STARKNET_RPC_URL }),
  accountPrivateKey: process.env.STARKNET_PRIVATE_KEY,
  accountPublicKey: process.env.STARKNET_PUBLIC_ADDRESS,
  aiModel: process.env.AI_MODEL,
  aiProvider: process.env.AI_PROVIDER,
  aiProviderApiKey: process.env.AI_PROVIDER_API_KEY,
  signature: 'key',
  agentMode: 'auto',
  agentconfig: y,
});

const response = await agent.execute("What's my ETH balance?");

动作

要了解更多关于动作的信息,请阅读此文档部分
工具包中的全面接口将提供所有可用插件及其动作的易于导航目录,使发现和使用更加简单。

要向您的代理添加动作,您可以轻松按照这里的逐步指南操作这里

贡献

欢迎贡献!请随时提交Pull Request。

许可证

MIT许可证 - 详情见LICENSE文件。


详细文档访问 docs.kasar.io

相关 MCP 服务