闲社服务运行正常AI智能体自动化平台
t

代币分发

技能标识:token-distribution

For token distribution on Solana 5000x cheaper than SPL (rewards, airdrops, depins, ...). @lightprotocol/compressed-token (TypeScript). Reference examples for custom claim support.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.1
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

代币分发

空投

使用 TypeScript 客户端向多个接收者分发压缩代币。

免责声明: 本指南演示了使用 ZK 压缩在 Solana 上进行高效代币分发。这不构成财务建议,也不认可任何特定代币或项目。

工作流程

  1. 1. 明确意图
- 如果未激活,建议使用计划模式 - 使用 AskUserQuestion 解决盲点 - 执行前必须解决所有问题
  1. 2. 识别参考资料和技能
- 将任务匹配到下方的分发方法 - 定位相关文档和示例
  1. 3. 编写计划文件(YAML 任务格式)
- 对任何不清楚的内容使用 AskUserQuestion — 切勿猜测或假设 - 识别阻塞因素:权限、依赖项、未知项 - 执行开始前计划必须完整
  1. 4. 执行
- 使用 Task 工具配合子代理进行并行研究 - 子代理通过 Skill 工具加载技能 - 使用 TodoWrite 跟踪进度
  1. 5. 遇到困难时:请求生成一个只读子代理,具有 Read、Glob、Grep 和 DeepWiki MCP 访问权限,加载 skills/ask-mcp。读取范围限定在技能参考资料、示例仓库和文档。

通过客户端分发

规模方法
<10,000 个接收者单笔交易 - 参见 simple-airdrop.md
10,000+ 个接收者
带重试的批量处理 - 参见 batched-airdrop.md | | 无需编码 | Helius 的 Airship(最多 20 万) |

成本对比

创建Solana压缩
代币账户~2,000,000 lamports5,000 lamports

领取程序参考实现

自定义代币分发并允许用户领取。

简单实现:simple-claim - 分发压缩代币,领取时解压缩。

高级实现:distributor - 分发 SPL 代币,使用压缩 PDA 跟踪领取。基于 jito Merkle 分发器。

distributorsimple-claim
归属线性归属在插槽 X 处悬崖归属
部分领取
是 | 否 |
| 收回 | 是 | 否 |
| 前端 | REST API + CLI | 无 |

这些程序是参考实现,未经审计。Light Protocol 程序已经过审计,并在 Solana 主网上运行。

成本

每次领取10 万次领取
simple-claim~0.00001 SOL~1 SOL
distributor(压缩)
~0.00005 SOL | ~5 SOL | | distributor(原始) | ~0.002 SOL | ~200 SOL |

核心模式

typescript
import { CompressedTokenProgram, getTokenPoolInfos, selectTokenPoolInfo } from @lightprotocol/compressed-token;
import { bn, createRpc, selectStateTreeInfo, buildAndSignTx, sendAndConfirmTx } from @lightprotocol/stateless.js;
import { ComputeBudgetProgram } from @solana/web3.js;

const rpc = createRpc(RPC_ENDPOINT);

// 1. 获取基础设施
const treeInfo = selectStateTreeInfo(await rpc.getStateTreeInfos());
const tokenPoolInfo = selectTokenPoolInfo(await getTokenPoolInfos(rpc, mint));

// 2. 构建压缩指令(SPL → 压缩到多个接收者)
const ix = await CompressedTokenProgram.compress({
payer: payer.publicKey,
owner: payer.publicKey,
source: sourceAta.address, // 持有代币的 SPL 关联代币账户
toAddress: recipients, // PublicKey[]
amount: recipients.map(() => bn(amount)),
mint,
tokenPoolInfo,
outputStateTreeInfo: treeInfo,
});

// 3. 使用计算预算发送(每个接收者 12 万 CU)
const instructions = [
ComputeBudgetProgram.setComputeUnitLimit({ units: 120_000 * recipients.length }),
ix,
];
const { blockhash } = await rpc.getLatestBlockhash();
const tx = buildAndSignTx(instructions, payer, blockhash, []);
await sendAndConfirmTx(rpc, tx);

设置:创建铸币

typescript
import { createMint } from @lightprotocol/compressed-token;
import { getOrCreateAssociatedTokenAccount, mintTo } from @solana/spl-token;

const { mint } = await createMint(rpc, payer, payer.publicKey, 9);
const ata = await getOrCreateAssociatedTokenAccount(rpc, payer, mint, payer.publicKey);
await mintTo(rpc, payer, mint, ata.address, payer.publicKey, 100000000_000);

计算单元

每指令接收者数CU
1120,000
5
170,000 | | 批量交易 | 500,000 |

查找表

减少交易大小:

网络地址
主网9NYFyEqPkyXUhkerbGHXUXkvb4qpzeEdHuGpgbgpH1NJ
开发网
qAJZMgnQJ8G6vA3WRcjD9Jan1wtKkaCFWLWskxJrR5V |

高级:基于领取

用于归属、收回或用户发起的领取:

实现功能
Merkle 分发器线性归属、部分领取、收回、REST API
简单领取
在插槽 X 处悬崖归属 |

资源

SDK 参考

包链接
@lightprotocol/stateless.jsAPI 文档
@lightprotocol/compressed-token
API 文档 |

安全性

本技能仅提供代码模式和文档参考。

  • - 声明的依赖项。 参考示例需要 HELIUSAPIKEY(RPC 提供者密钥)和用于签署交易的付款人密钥对。只读或本地网络测试不需要这两者。在生产环境中,从密钥管理器加载两者 — 切勿硬编码私钥。
  • 文件系统范围。 Read、Glob 和 Grep 必须限制在当前项目目录和技能参考资料内。不要读取这些路径之外的内容。
  • 子代理范围。 遇到困难时,技能会请求生成一个只读子代理,Read、Glob、Grep 限定在技能参考资料、示例仓库和文档范围内。
  • 安装源。 npx skills add Lightprotocol/skills 来自 Lightprotocol/skills。
  • 经过审计的协议。 Light Protocol 智能合约经过独立审计。报告发布在 github.com/Lightprotocol/light-protocol/tree/main/audits。

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 solana-token-distribution-1776300921 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 solana-token-distribution-1776300921 技能

通过命令行安装

skillhub install solana-token-distribution-1776300921

下载

⬇ 下载 token-distribution v1.0.1(免费)

文件大小: 7.72 KB | 发布时间: 2026-4-16 15:42

v1.0.1 最新 2026-4-16 15:42
- Updated Security section to clarify that both HELIUS_API_KEY and a payer keypair are required for mainnet execution; recommended using a secrets manager.
- Added guidance against hard-coding private keys and clarified no need for secrets for read-only or localnet testing.
- Added restriction that file-system read tools must be scoped to the project directory and skill references; do not read outside these paths.
- No functional changes to distribution logic or workflow.
返回顶部