微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🎰

Solana 链上 AI 模型竞技投注

crewmind-bets · vv1.0.0
专业技能 安全 S 级 作者 vladthecto 公开目录收录
下载 1.9k 安装 505 收藏 7.1k 浏览 65.7k
原始页面

简介

基于 Solana 智能合约的 LLM 竞技场投注工具,支持对 OpenAI、DeepSeek 等顶尖模型竞赛结果进行链上投注并赢取奖励。

原始描述

Place bets in CrewMind Arena on AI models competing in each round and claim rewards if your chosen model wins after finalization.

中文使用说明 来自收录源

核心用法

CrewMind Arena Betting Skill 是一份纯文档型技术指南,提供在 Solana 主网上进行 AI 模型竞猜投注的完整开发文档。核心功能围绕两个链上指令:

  1. place_bet(ship, amount) — 对指定 AI 模型(OpenAI/DeepSeek/Grok/Gemini)下注 SOL
  2. claim() — 轮次结束后若投注模型获胜,领取奖励(本金+输家池分成)

文档详细列出了 Program ID、PDA 派生种子、账户结构解析、指令数据布局及完整 JavaScript 代码示例,开发者可按此构建投注客户端。

显著优点

  • 纯文档零执行风险:T-MD 分类,无可执行代码,仅作为技术参考
  • 技术透明度高:完整公开合约地址、账户结构、错误码等链上交互细节
  • 安全提示完善:文档内嵌多条安全规则(检查 end_ts、验证 round 状态、金额边界等)
  • 代码示例规范:使用标准 Solana Web3.js 和 Anchor 模式,无危险函数

潜在缺点与局限性

  • 域名可信度存疑:项目官网 crewmind.xyz 使用低成本 .xyz 域名,常被钓鱼滥用
  • 无项目背景验证:无法确认 CrewMind Arena 项目方的真实运营状况
  • 智能合约风险:即使文档真实,链上合约仍可能存在漏洞或后门
  • 资金完全托管:投注 SOL 锁定于合约 Vault,项目方具备理论控制权限
  • 仅限主网:无测试网支持,开发者无法零成本验证

适合人群

  • 具备 Solana 开发经验、希望了解/构建链上投注前端的技术人员
  • 熟悉区块链风险、能自主验证合约地址的 DeFi 资深用户
  • 研究 AI 模型竞技预测市场机制的分析师

常规风险

风险类型 等级 说明
钓鱼域名 中高 .xyz 域名需交叉验证官方渠道
合约漏洞 中高 未审计代码可能存在资金损失风险
项目方跑路 中 项目运营方身份不明,存在托管风险
投注损失 高 竞猜本身即高风险,可能全额损失本金
私钥泄露 中 使用示例代码时若硬编码密钥则危险

关键建议:任何资金操作前,务必通过 Solana Explorer 验证 Program ID,小额测试,且仅投入可承受损失的资金。

技能正文

CrewMind Arena Betting Skill

TL;DR: Place bets on LLM models competing in CrewMind Arena. Bet on which AI wins each round, claim rewards if your model wins.

Quick Start

npm install @solana/web3.js @coral-xyz/anchor dotenv

Program Info

Parameter Value
Program ID F5eS61Nmt3iDw8RJvvK5DL4skdKUMA637MQtG5hbht3Z
Network Solana Mainnet
Website https://crewmind.xyz

Ship Index Mapping

Index Model
0 OpenAI
1 DeepSeek
2 Grok
3 Gemini

PDA Seeds

Account Seeds
Config ["config"]
Round ["round", config, round_id]
Bet ["bet", round, user]
Vault ["vault", round]

Instruction Discriminators

Instruction Discriminator (bytes)
place_bet [222, 62, 67, 220, 63, 166, 126, 33]
claim [62, 198, 214, 193, 213, 159, 108, 210]

Account Structures

Config Account (120 bytes)

Offset  Size  Field
─────────────────────────────────
0       8     discriminator
8       32    admin (Pubkey)
40      32    treasury (Pubkey)
72      8     next_round_id (u64)
80      32    active_round (Pubkey) ← use this!
112     8     active_round_id (u64)

Round Account (190 bytes)

Offset  Size  Field
─────────────────────────────────
0       8     discriminator
8       8     id (u64)
16      1     status (u8: 0=Open, 1=Finalized)
17      1     ship_count (u8)
18      1     winner_ship (u8, 255=unset)
19      1     swept (bool)
20      8     start_ts (i64)
28      8     end_ts (i64)
36      8     finalized_ts (i64)
44      8     min_bet (u64)
52      8     max_bet (u64)
60      2     participants (u16)
62      8     total_staked (u64)
70      32    totals_by_ship ([u64; 4])
102     64    weighted_by_ship ([u128; 4])
166     8     losing_pool (u64)
174     16    total_weighted_winners (u128)

Bet Account (96 bytes)

Offset  Size  Field
─────────────────────────────────
0       8     discriminator
8       1     initialized (bool)
9       32    round (Pubkey)
41      32    user (Pubkey)
73      1     ship (u8)
74      1     claimed (bool)
75      6     _pad
81      8     total_amount (u64)
89      16    total_weighted (u128)

Entrypoint: place_bet

Goal

Place a bet on a ship (AI model) in the active round.

Instruction

place_bet(ship: u8, amount: u64)

Accounts (in order)

# Account Signer Writable Description
0 user ✓ ✓ Your wallet
1 config PDA ["config"]
2 round ✓ Active round pubkey from config
3 bet ✓ PDA ["bet", round, user]
4 vault ✓ PDA ["vault", round]
5 system_program 11111111111111111111111111111111

Constraints

  • ship < ship_count (usually 4)
  • min_bet <= amount <= max_bet
  • current_time < end_ts
  • Round status must be Open (0)

Instruction Data Layout

Bytes 0-7:   discriminator [222, 62, 67, 220, 63, 166, 126, 33]
Byte 8:     ship (u8)
Bytes 9-16: amount (u64 LE)

Entrypoint: claim

Goal

Claim rewards after round finalization (if your ship won).

Instruction

claim() — no arguments

Accounts (in order)

# Account Signer Writable Description
0 user ✓ ✓ Your wallet
1 round The finalized round
2 bet ✓ PDA ["bet", round, user]
3 vault ✓ PDA ["vault", round]
4 system_program 11111111111111111111111111111111

Constraints

  • Round status must be Finalized (1)
  • Your bet's ship == winner_ship
  • claimed == false

Instruction Data Layout

Bytes 0-7: discriminator [62, 198, 214, 193, 213, 159, 108, 210]

Errors

Code Name Description
6004 InvalidShip Ship index >= ship_count
6005 RoundNotOpen Round is finalized
6006 RoundEnded Past end_ts
6008 RoundNotFinalized Can't claim yet
6009 TooLate Too late to bet
6011 InvalidBetAmount Amount out of bounds
6014 AlreadyClaimed Already claimed
6015 NotAWinner Your ship didn't win

Complete JavaScript Example

import { Connection, PublicKey, Keypair, Transaction, TransactionInstruction, SystemProgram } from '@solana/web3.js';

const PROGRAM_ID = new PublicKey('F5eS61Nmt3iDw8RJvvK5DL4skdKUMA637MQtG5hbht3Z');
const SHIPS = { openai: 0, deepseek: 1, grok: 2, gemini: 3 };

async function getActiveRound(connection) {
  const [configPda] = PublicKey.findProgramAddressSync([Buffer.from('config')], PROGRAM_ID);
  const configAccount = await connection.getAccountInfo(configPda);
  if (!configAccount) throw new Error('Config not found');

  const activeRound = new PublicKey(configAccount.data.slice(80, 112));
  if (activeRound.equals(PublicKey.default)) throw new Error('No active round');

  return { configPda, activeRound };
}

async function getRoundInfo(connection, roundPubkey) {
  const acc = await connection.getAccountInfo(roundPubkey);
  if (!acc) throw new Error('Round not found');
  const d = acc.data;

  return {
    id: d.readBigUInt64LE(8),
    status: d.readUInt8(16),           // 0=Open, 1=Finalized
    shipCount: d.readUInt8(17),
    winnerShip: d.readUInt8(18),       // 255 if not set
    startTs: d.readBigInt64LE(20),
    endTs: d.readBigInt64LE(28),
    minBet: d.readBigUInt64LE(44),
    maxBet: d.readBigUInt64LE(52),
  };
}

async function placeBet(connection, wallet, shipName, amountSol) {
  const ship = SHIPS[shipName.toLowerCase()];
  const amountLamports = BigInt(Math.floor(amountSol * 1e9));

  const { configPda, activeRound } = await getActiveRound(connection);
  const roundInfo = await getRoundInfo(connection, activeRound);

  // Validations
  if (roundInfo.status !== 0) throw new Error('Round not open');
  if (BigInt(Date.now() / 1000) >= roundInfo.endTs) throw new Error('Round ended');
  if (amountLamports < roundInfo.minBet || amountLamports > roundInfo.maxBet) {
    throw new Error(`Amount must be between ${Number(roundInfo.minBet)/1e9} and ${Number(roundInfo.maxBet)/1e9} SOL`);
  }

  const [betPda] = PublicKey.findProgramAddressSync(
    [Buffer.from('bet'), activeRound.toBuffer(), wallet.publicKey.toBuffer()], PROGRAM_ID
  );
  const [vaultPda] = PublicKey.findProgramAddressSync(
    [Buffer.from('vault'), activeRound.toBuffer()], PROGRAM_ID
  );

  const data = Buffer.concat([
    Buffer.from([222, 62, 67, 220, 63, 166, 126, 33]), // discriminator
    Buffer.from([ship]),                                // ship u8
    (() => { const b = Buffer.alloc(8); b.writeBigUInt64LE(amountLamports); return b; })()
  ]);

  const ix = new TransactionInstruction({
    keys: [
      { pubkey: wallet.publicKey, isSigner: true, isWritable: true },
      { pubkey: configPda, isSigner: false, isWritable: false },
      { pubkey: activeRound, isSigner: false, isWritable: true },
      { pubkey: betPda, isSigner: false, isWritable: true },
      { pubkey: vaultPda, isSigner: false, isWritable: true },
      { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
    ],
    programId: PROGRAM_ID,
    data,
  });

  const tx = new Transaction().add(ix);
  tx.feePayer = wallet.publicKey;
  tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
  tx.sign(wallet);

  return await connection.sendRawTransaction(tx.serialize());
}

async function claim(connection, wallet, roundPubkey) {
  const roundInfo = await getRoundInfo(connection, roundPubkey);
  if (roundInfo.status !== 1) throw new Error('Round not finalized yet');

  const [betPda] = PublicKey.findProgramAddressSync(
    [Buffer.from('bet'), roundPubkey.toBuffer(), wallet.publicKey.toBuffer()], PROGRAM_ID
  );
  const [vaultPda] = PublicKey.findProgramAddressSync(
    [Buffer.from('vault'), roundPubkey.toBuffer()], PROGRAM_ID
  );

  const data = Buffer.from([62, 198, 214, 193, 213, 159, 108, 210]); // claim discriminator

  const ix = new TransactionInstruction({
    keys: [
      { pubkey: wallet.publicKey, isSigner: true, isWritable: true },
      { pubkey: roundPubkey, isSigner: false, isWritable: false },
      { pubkey: betPda, isSigner: false, isWritable: true },
      { pubkey: vaultPda, isSigner: false, isWritable: true },
      { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
    ],
    programId: PROGRAM_ID,
    data,
  });

  const tx = new Transaction().add(ix);
  tx.feePayer = wallet.publicKey;
  tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
  tx.sign(wallet);

  return await connection.sendRawTransaction(tx.serialize());
}

// Usage:
// const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
// const wallet = Keypair.fromSecretKey(...);
// await placeBet(connection, wallet, 'deepseek', 0.01);

Workflow Summary

1. GET ACTIVE ROUND
   └─> Read Config PDA → get active_round pubkey

2. CHECK ROUND STATUS
   └─> Read Round account → verify status=0 (Open), check end_ts

3. PLACE BET
   └─> Call place_bet(ship, amount)
   └─> Creates Bet PDA, transfers SOL to Vault

4. WAIT FOR ROUND TO END
   └─> Monitor: current_time > end_ts

5. WAIT FOR FINALIZATION
   └─> Monitor: Round.status == 1 (Finalized)
   └─> Check: Round.winner_ship

6. CLAIM (if won)
   └─> Call claim() if your ship == winner_ship
   └─> Receives: original_bet + share_of_losing_pool

Safety Rules

  • Never bet more than max_bet
  • Check end_ts before betting (avoid TooLate error)
  • Only one bet per round per user (but can add to existing bet)
  • Always verify round is Open before betting
  • Always verify round is Finalized before claiming
  • Keep SOL for transaction fees (~0.002 SOL recommended buffer)

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

payfinance-accountingapidevelopment-engineeringblockchain

同类 Skill