当前位置: 首页 > Skill >

TokenDraft

TokenDraft

TokenDraft

TokenDraft幻想加密竞赛完整套件——使用Solana钱包认证、查询/加入/自动加入竞赛,以及管理自动选秀资产

1.0.1 2026.11.04 269
获取Skill文件查看使用说明
作 者:叶澄 许可证: 更新时间:2026.11.04
本文目录展开

TokenDraft Authentication

Two-step challenge-response flow. Private key never leaves the local environment.

After successful login, store TOKENDRAFT_USER_ID (from user.id) and TOKENDRAFT_JWT (from token) as env vars. These are required by all other TokenDraft endpoints.

If any TokenDraft endpoint returns 401, re-run this auth flow automatically and retry the failed request.

Step 1: Request a Nonce

curl -X POST https://tokendraft-production.up.railway.app/api/v2/agents/nonce 
  -H "Content-Type: application/json" 
  -d '{"walletPublicKey": "<WALLET_PUBLIC_KEY>"}'

Returns { nonce, message }. The message is the exact string to sign. Nonce expires after 5 minutes, single-use.

Step 2: Sign and Log In

Sign message locally with Ed25519, base58-encode the signature:

curl -X POST https://tokendraft-production.up.railway.app/api/v2/agents/login 
  -H "Content-Type: application/json" 
  -d '{
    "walletPublicKey": "<WALLET_PUBLIC_KEY>",
    "nonce": "<NONCE>",
    "signature": "<BASE58_SIGNATURE>"
  }'

Returns { token, user }. First login auto-creates an account.

On first login (the user's displayName is a short hash like "a3F9x"), ask the user if they'd like to set a display name. If yes, call the Update Display Name endpoint below.

Update Display Name

curl -X POST "https://tokendraft-production.up.railway.app/api/v2/users/displayName" 
  -H "Authorization: Bearer $TOKENDRAFT_JWT" 
  -H "Content-Type: application/json" 
  -d '{"displayName": "<NEW_NAME>"}'

Constraints: display name must be unique across all users. Can only be changed once every 24 hours. HTTP 429 is returned with retryAfterMs if rate-limited.

Signing Reference

import nacl from 'tweetnacl';
import bs58 from 'bs58';

const secretKey = bs58.decode(process.env.SOLANA_PRIVATE_KEY);
const keyPair = nacl.sign.keyPair.fromSecretKey(secretKey);
const walletPublicKey = bs58.encode(keyPair.publicKey);

// Step 1
const { nonce, message } = await fetch('https://tokendraft-production.up.railway.app/api/v2/agents/nonce', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ walletPublicKey }),
}).then(r => r.json());

// Step 2
const messageBytes = new TextEncoder().encode(message);
const signature = nacl.sign.detached(messageBytes, keyPair.secretKey);
const signatureBase58 = bs58.encode(signature);

const { token, user } = await fetch('https://tokendraft-production.up.railway.app/api/v2/agents/login', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ walletPublicKey, nonce, signature: signatureBase58 }),
}).then(r => r.json());

Token Usage

Include in all authenticated requests:

Authorization: Bearer $TOKENDRAFT_JWT

Token does not expire but may be invalidated on server secret rotation.

TokenDraft Tournaments

All endpoints use base URL https://tokendraft-production.up.railway.app and require Authorization: Bearer $TOKENDRAFT_JWT. Re-authenticate via the auth flow above on 401.

Query Tournaments

curl "https://tokendraft-production.up.railway.app/api/v2/agents/tournaments?<PARAMS>" 
  -H "Authorization: Bearer $TOKENDRAFT_JWT"
Param Type Description
isOpen boolean Accepting registrations
isInProgress boolean Currently being played
isFinished boolean Completed
isRegistered boolean Filter by user's registration status
finishedLookbackHours number Hours to look back for finished (default: 24, 0 = all)

Filters combine with AND. No state filter defaults to open tournaments only.

Returns array of TournamentSummary:

{ id: string, name: string, buyInAmountSol: number, registrationStartTime: string,
  registrationEndTime: string, state: string, numPlayersRegistered: number,
  maxPlayers: number, amIRegistered: boolean,
  draftType: "snake" | "boosterPack" | "instantRoster",
  rosterSlots: { Chain?: number, Meme?: number, Utility?: number, NFT?: number, Flex?: number } }

Join Free Tournament

If buyInAmountSol is 0:

curl -X POST "https://tokendraft-production.up.railway.app/api/v2/tournaments/join/<TOURNAMENT_ID>" 
  -H "Authorization: Bearer $TOKENDRAFT_JWT"

HTTP 200 = registered. Relay any error to the user.

Update asset priority rankings if this is an instant roster tournament.

Join Paid Tournament (Buy-In)

For buyInAmountSol > 0, verify SOL balance covers the buy-in + fees first.

1. Initiate transaction:

curl -X POST "https://tokendraft-production.up.railway.app/api/v2/buyIn/initiateTransaction" 
  -H "Authorization: Bearer $TOKENDRAFT_JWT" 
  -H "Content-Type: application/json" 
  -d '{"tournamentId": "<ID>", "walletPublicKey": "<PUBKEY>"}'

Returns { transaction (base64), expectedSignature, tournamentInfo }.

2. Sign: Deserialize transaction as VersionedTransaction, sign with wallet keypair, re-serialize to base64.

3. Send signed transaction:

curl -X POST "https://tokendraft-production.up.railway.app/api/v2/buyIn/sendSignedTransaction" 
  -H "Content-Type: application/json" 
  -d '{
    "signedTransactionBase64": "<BASE64>",
    "tournamentId": "<ID>",
    "expectedSignature": "<SIG>",
    "walletPublicKey": "<PUBKEY>"
  }'

HTTP 200 = registered. Relay errors (tournament full, already registered, on-chain failure).

Update asset priority rankings if this is an instant roster tournament.

Instant Roster Tournaments

When draftType is "instantRoster", the system auto-drafts the entire roster instantly from the player's asset priority rankings. There is no live draft — all picks happen at machine speed with 0-second turns. Duplicates between players are allowed (two players can have the same token), but a player cannot have the same token twice.

After joining an instantRoster tournament, you MUST set asset priority rankings so the auto-drafter knows what to pick.

How to build rankings that fulfil roster slots

The tournament's rosterSlots tells you how many assets of each type are needed. Each asset from GET /api/v2/assets has an assetType field (e.g. "Chain", "Meme", "Utility", "NFT"). The "Flex" slot accepts any type.

Steps:

  1. Fetch assets: GET /api/v2/assets — returns [{ id, name, ticker, assetType, priceUSD, marketcapUSD, dayChangePercent, dayVolumeUSD, ... }]
  2. Read rosterSlots from the tournament (e.g. { "Chain": 2, "Meme": 2, "Utility": 1, "NFT": 1, "Flex": 1 })
  3. For each slot type (except Flex), pick the best assets of that assetType based on user strategy
  4. For the Flex slot(s), pick the best remaining asset of any type
  5. If a slot is not present, or has value <= 0, ignore all assets of that type when ranking.
  6. Submit as ranked list via PUT /api/v2/assetPriorityRankings

Example — given rosterSlots: { "Chain": 2, "Meme": 2, "Utility": 1, "NFT": 1, "Flex": 1 } and a "highest market cap" strategy:

assets = GET /api/v2/assets
Sort assets by marketcapUSD descending within each assetType:
  chains  = assets.filter(a => a.assetType === "Chain").sort(by marketcapUSD desc)
  memes   = assets.filter(a => a.assetType === "Meme").sort(by marketcapUSD desc)
  utils   = assets.filter(a => a.assetType === "Utility").sort(by marketcapUSD desc)
  nfts    = assets.filter(a => a.assetType === "NFT").sort(by marketcapUSD desc)

Pick top N for each slot:
  rank 1: chains[0]    (Chain slot 1)
  rank 2: chains[1]    (Chain slot 2)
  rank 3: memes[0]     (Meme slot 1)
  rank 4: memes[1]     (Meme slot 2)
  rank 5: utils[0]     (Utility slot)
  rank 6: nfts[0]      (NFT slot)
  rank 7: best remaining asset of any type (Flex slot)

Anything set to rank 1 will be selected as "captain", and be worth double points, so set rank 1 as best overall pick within roster.

PUT /api/v2/assetPriorityRankings with:
  { "assets": [{"assetId":"<chains[0].id>","rank":1}, ...], "autoDraftStrategy": "MKT_CAP_DESC" }

Full flow for instantRoster tournaments

  1. Query open tournaments and find one with draftType === "instantRoster"
  2. Join the tournament (free or paid flow as above)
  3. Fetch assets from GET /api/v2/assets
  4. Build a ranked list of 7 assets that fulfil the tournament's rosterSlots, using the user's preferred strategy (ask if not known)
  5. Submit rankings via PUT /api/v2/assetPriorityRankings
  6. Report to the user which assets were picked for each slot and ask if they want to make any changes before the draft starts
  7. If the user requests changes, update rankings accordingly and re-submit

Auto-Join (Cron)

Set up a cron job to join all open tournaments every 30 minutes:

openclaw cron add 
  --name "tokendraft-auto-join" 
  --cron "*/30 * * * *" 
  --session isolated 
  --message "Auto-join open TokenDraft tournaments. Steps:
1. Authenticate with TokenDraft (see auth section above).
2. GET /agents/tournaments?isOpen=true&isRegistered=false to find open tournaments.
3. For each: if buyInAmountSol is 0, POST /tournaments/join/<id>. If > 0, check SOL balance and follow buy-in flow.
4. If the joined tournament has draftType 'instantRoster', also set asset priority rankings that fulfil the rosterSlots.
5. Report results for each tournament (joined or error reason)."

Manage with openclaw cron list, openclaw cron remove <id>, openclaw cron edit <id> --enabled false/true.

TokenDraft Asset Rankings

All endpoints use base URL https://tokendraft-production.up.railway.app and require Authorization: Bearer $TOKENDRAFT_JWT. Re-authenticate via the auth flow above on 401.

Step 1: Ask the User for Ranking Advice

Ask how they want assets ranked before fetching data (e.g. by market cap, volume, buy the dip, memecoins first).

Step 2: Fetch Assets

curl "https://tokendraft-production.up.railway.app/api/v2/assets" 
  -H "Authorization: Bearer $TOKENDRAFT_JWT"

Returns array of assets with fields: id, name, ticker, priceUSD, marketcapUSD, dayChangePercent, dayVolumeUSD, adpRanking, assetType, tags.

Step 3: Rank

Assign each asset a rank from 1 (drafted first) to N (last). Use the user's advice combined with financial data.

Built-in strategies (set as autoDraftStrategy to use instead of manual ranks):

VOL_24H_DESC, VOL_24H_ASC, MKT_CAP_ASC, MKT_CAP_DESC, ADP, PERCENT_24H_ASC, PERCENT_24H_DESC

Step 4: Submit Rankings

curl -X PUT "https://tokendraft-production.up.railway.app/api/v2/assetPriorityRankings" 
  -H "Authorization: Bearer $TOKENDRAFT_JWT" 
  -H "Content-Type: application/json" 
  -d '{
    "assets": [{"assetId": "<ID>", "rank": 1}, ...],
    "autoDraftStrategy": "PERCENT_24H_DESC"
  }'

Include only the top 7 assets. Set rank to unique integers. autoDraftStrategy is required, so default to "PERCENT_24H_DESC" if not specified by user. This is the fallback if any assets are unavailable from rankings.

Auto-Update Rankings (Cron)

Ask the user for ranking advice and update frequency, then create a cron job:

openclaw cron add 
  --name "tokendraft-auto-rank" 
  --cron "<CRON_EXPRESSION>" 
  --session isolated 
  --message "Update TokenDraft rankings. Steps:
1. Authenticate (see auth section above).
2. GET /api/v2/assets for current data.
3. Rank all assets 1-N based on: <USER_RANKING_ADVICE>.
4. PUT /api/v2/assetPriorityRankings with ranked list.
5. Report success or failure."

Manage with openclaw cron list, openclaw cron remove <id>, openclaw cron edit <id> --enabled false/true.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,003
Apache开启.htaccess及使用方法详解

本文介绍如何在本地Apache环境中启用.htaccess文件,主要涉及修改httpd.conf中的AllowOverride参数。同时详细解析.htaccess的多种实用功能,包括自定义错误页面、目录密码保护、IP访问限制、URL自动转向、默认首页设置以及防止图片盗链等配置方法,并分析了使用.htaccess对服务器性能和安全性的潜在影响。

2026.05.09 1,001
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,001
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,000
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,000
Skill 文件
  • SKILL.md
    • TokenDraft Authentication
    • Step 1: Request a Nonce
    • Step 2: Sign and Log In
    • Update Display Name
    • Signing Reference
    • Token Usage
    • TokenDraft Tournaments
    • Query Tournaments
    • Join Free Tournament
    • Join Paid Tournament (Buy-In)
    • Instant Roster Tournaments
      • How to build rankings that fulfil roster slots
      • Full flow for instantRoster tournaments
    • Auto-Join (Cron)
    • TokenDraft Asset Rankings
    • Step 1: Ask the User for Ranking Advice
    • Step 2: Fetch Assets
    • Step 3: Rank
    • Step 4: Submit Rankings
    • Auto-Update Rankings (Cron)
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期