# @flop-labs/sdk 中文文档

规范地址：https://npmcn.com/package/%40flop-labs/sdk/

版本：0\.6\.0
npm 元数据更新时间：2026-11-12T03:39:23.818Z
中文译文更新时间：2026-11-14T23:52:35.880Z
软件包许可：MIT OR Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40flop-labs/sdk
原文对照：https://npmcn.com/package/%40flop-labs/sdk/?lang=original
项目主页：https://github.com/flop-labs/flop-core#readme
源码仓库：https://github.com/flop-labs/flop-core

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：14.8 MB，689 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：10 个
- peer 依赖：react \>=18\.0\.0，@ton/ton ^16\.3\.0，@ton/core ^0\.63\.1，@ton/crypto ^3\.3\.0，near-api-js \*，@polkadot/hw-ledger \*，@walletconnect/modal \*，@polkadot/extension-dapp \*，@walletconnect/universal-provider \*
- 首次发布：2026-10-29T04:00:53.210Z
- 最新版本发布：2026-11-12T03:39:23.498Z
- 近 30 天下载量：3449（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：5（近 12 个月 5 个）

## 中文简介

FLOP 网络的 TypeScript SDK – HTLC 工作流程、 PoUI 证明和账户管理

## 安装

```sh
npm install @flop-labs/sdk
```

也可以使用：`pnpm add @flop-labs/sdk`、`yarn add @flop-labs/sdk`、`bun add @flop-labs/sdk`

## README

# @flop-labs/ sdk (英语)

`FaucetClient.healthCheck()` 报告水龙头的HTTP准备状态为布尔. 它回来了 `false` hTTP 503 或请求失败,包括活水龙头 其调用IP的分类没有被检查. 这不是过程活性 或授予资格测试。 健康协会不要求资金或对IP进行分类. 明确 `requestFaucetFunding()` 尝试执行录入并返回 a 拒绝理由和 `retryAfterSeconds` 当供应。 从不自动 重复资助 POST 。 一个 `unknown` 结果可以指赠款的发生: 在再次提出要求之前,结果和调和。 健康检查不能单独进行 阻断明确的供资请求.

**未释放水龙头迁移:** `fundFromFaucet` 保留其布尔签名 但目前总是返回 `false`;虚假意味着未经证实,而不是未付. 这个 水龙头还没有从独特的请求中暴露出经认证的可持久约束力 因此,SDK不能建立特定请求的确认. 使用 `fundFromFaucetDetailed` 区分拒绝、无法飞行前和 未知结果,并保留返回的散列。 它被接受的HTTP 答复仍为赠款。 快速启动抛出 `FaucetUnconfirmedError` 与无法确认供资时的结果;对原请求进行核对 重试之前。 Faucet启用的QuickStart需要呼叫者拥有的签名人或键盘包 因此,未经证实的付款不能被困在无法进入的生成钱包中。 对于账户资金是否充足这一单独问题, 使用情况 `waitForAvailableBalance`;旧的 `waitForFaucetFunding` 名称已贬值 平衡检查别名。 没有任何仅以来源为主的测试证实有现场补助.

普通HTLC的创建需要注册的"经济批评评价简介". 供应 `tee_requirements` 编号 : `teeRequirements` 作为 `{profile: {profile_id, version}, model_hash, measurement_hash}` (32字节的六分法),或其犬形100字节的SCALE六分法. 运行时间检查注册的剖面图和不可改变的承诺是否符合其政策;不存在模拟默认. 实例,设定 `FLOP_HTLC_TEE_REQUIREMENTS` 从你网络的注册档案里找到的.

用于FLOP网络的TypeScript SDK——HTLC工作流程,PoI证明,以及账户管理.

`SUPPORTED_SPEC_VERSIONS` 准确的承认 `1013000`, (中文(简体) ), `1014000`, (中文(简体) ), `1014001`, (中文(简体) ), `1014002`, (中文(简体) ), `1014003`, (中文(简体) ), `1014004`, (中文(简体) ), `1014005`, (中文(简体) ), `1014007`, (中文(简体) ), `1014008`, (中文(简体) ), `1014009`, (中文(简体) ), `1014010`, (中文(简体) ), `1014011`, (中文(简体) ), `1014012`, (中文(简体) ), `1014013`, (中文(简体) ), `1014014`, (中文(简体) ), `1014015`, (中文(简体) ), `1014016`, (中文(简体) ), `1014017`, (中文(简体) ), `1014018`, (中文(简体) ), `1014019`, (中文(简体) ), `1014020`。 。 。 . `SUPPORTED_SPEC_VERSION_RANGE` 保留其导出形状为信封 `1013000..1014020`; 接纳需要确切的成员资格(包括否) `1014006`) (中文(简体) ). 发表 `0.4.0` 可执行文件在 `1014011` 并排除 `1014006`· ; 其捆绑的README有Stale连接和HTLC实例. 这些来源更正 未释放:安装 `@latest` 在新版本完成之前不交付 发表。 以下例子说明了这一来源候选人。 资格涵盖 运行时间 `1013000` 时间 `44a5fedc88614b9a6e8c97605c2ec943faf47d9d`,则 书记官长运行时间 `1014000` 时间 `e4f01cc849fa6c768d5c0f9c111dffb450ea4fa9` (PR # 2726) 运行时间 `1014001` 时间 `de4e2779dbf6f8d25348953ce0992ef8e89756bd` (PR #2803),运行时间 `1014002`,#2637devnet 混合验证快速路径,运行时间 `1014003` 时间 `9035450361681a69c6c02c9c53e47351999ef6f8` (PR #3096) (中文(简体) ). 候选人运行时间 `1014004` 1.14.4, PR #3006 对上传器供资的源兼容性覆盖 资格。 候选人运行时间 `1014005` 1.14.5 具有源兼容性覆盖 预激活 FCU 名称替换; 这不限制物理延迟或部署. 候选人的规格 `1014003` 有源兼容性覆盖; 由 sDK没有建立部署或端到端推断资格. 其他版本需要单独限定. 每个 `FlopClient` 连接路径检查 。 检测到不支持的运行时间升级 由 polkadot.js 元数据事件断开 API 并让随后的 SDK 操作 提高 `FlopError` 有代码 `RUNTIME_INCOMPATIBLE`,合格版本,并升级指导. 生成的客户端应用相同的精确版本守护;明确的配置限制可以 狭义相容并需要一个 spec 名称。 升级方式 `pnpm add @flop-labs/sdk@latest` 释放 支持链条的运行时间;允许列表更改需要兼容性验证.

## 安装

```bash
npm install @flop-labs/sdk
```

### 同伴依赖关系

反应是可选的( 仅在使用反应钩时需要):

```bash
npm install @flop-labs/sdk react  # Optional: for React integration
```

## 快速启动

2026年11月3日 光谱 `1014003`,带有空 `attest.profiles` 登记。 下面的HTLC例 除非经授权的治理部门登记其确切的经济状况,否则不能在那里运行 评估政策、核查器和版本。 既不模拟模式,也不任意 配置标识提供这个先决条件 。 使用 `assertHtlcAppraisalProfile(api, hex)` ; 运行时间独立执行政策和承诺. 3个被输出的幽灵/TOPOC/DA简介参考不是HTLC简介.

对于直接计算渠道购买,准备并坚持原意:

```typescript
import { FlopClient } from '@flop-labs/sdk';
import { readFile, writeFile } from 'node:fs/promises';

const client = await FlopClient.createWithKeypair('wss://rpc.devnet.flop.network', keypair);
try {
  // Run preparation once, in a private directory. The intent contains a session seed.
  const intent = await client.prepareInferenceSession({ minerUrl, escrowFlop: 0.01, maxTurns: 1 });
  await writeFile('purchase.json', JSON.stringify(intent), { flag: 'wx', mode: 0o600 });
  const saved = JSON.parse(await readFile('purchase.json', 'utf8'));
  const result = await client.buyInferenceSession({ intent: saved, prompt: 'Hello' });
  console.log(result.channelId, result.status);
} finally { await client.disconnect(); }
```

重新启动时, 读取已有文件并传递此意图; 永远不要运行准备 同样的购买。 使用文件时持有文件独占权. 或者, `buyInferenceSession` 接受等待的状态 `onPrepared` 持久性 调用。 无意致电或召回 签署前停止。 这么紧 之前的便利API,需要突破更改发布. SDK在提交前读取最终状态. 一个缺失的记录仍然是 未确认的结果; 重新提交保留了原频道的非ce和密钥 . 已有频道停止 `INFERENCE_PURCHASE_UNCONFIRMED` 及其公共身份证. 连 `Open` 可能是流出出链外转盘:不要用新鲜的计数器重放. 检查和解或收回保留记录;如果未交付 频道超过它的 SLA, 在确认后使用无权限的超时路径 资格。 在追回和结算/退款最后确定之前,保留意图. 重复的外科医生仍可支付费用. `settlement_posted` 打开挑战 窗口,没有确定最后的矿工付款.

```typescript
import { FlopClient, createAgentWallet } from '@flop-labs/sdk';

// Connect to FLOP node
const client = await FlopClient.create({ endpoint: 'ws://127.0.0.1:9944', signer: '//Alice' });

// Check node health
const health = await client.health();
console.log('Node healthy:', health);

// Create an agent wallet
const wallet = await createAgentWallet(client.api, client.signer, {
  agent: client.address,
  dailyCap: 100n * 10n ** 18n,
  perTxLimit: 5n * 10n ** 18n,
});

// Create HTLC for inference purchase
const htlc = await client.createHtlc({
  agent: 'my-agent',
  task: {
    model: 'llama-3-8b',
    prompt: 'Hello, world!',
    tee_requirements: process.env.FLOP_HTLC_TEE_REQUIREMENTS
  },
  rewardFlop: 5.0,
  timeoutBlocks: 60
});

console.log('HTLC created:', htlc.htlcId);

// Wait for settlement
const status = await client.waitForSettlement(htlc.hashLock);
console.log('Settlement:', status);
```

## API 参考

### 流线

与 FLOP 网络互动的主要客户端.

#### 连接工厂

```typescript
await FlopClient.create(options?: FlopClientOptions)
```

**选项 :**

-   `endpoint` (字符串,可选):RPC端点URL. 默认 : `ws://127.0.0.1:9944`
-   `signer` (字符串,可选):本地签名人URI `//Alice` 默认只用于可支配本地开发.
-   `createWithKeypair(endpoint, keypair)`: 使用已解码的键盘连接 .

#### 方法

##### `health()`

检查节点健康状况.

```typescript
await client.health();
// Returns: { isSyncing: boolean, peers: number, shouldHavePeers: boolean }
```

##### `createHtlc(params)`

创建用于购买原子推论的 Hash 时间锁定合同 .

```typescript
await client.createHtlc({
  agent: string,
  task: ComputeTask,
  rewardFlop: number,
  timeoutBlocks: number,
  hashLock?: string  // Auto-generated if not provided
});
```

**回返情况:**

```typescript
{
  htlcId: string;
  hashLock: string;
  preImage: string;
  txHash: string;
}
```

##### `createCrossChainHtlc(params)`

为 FLOP QQ BTC 原子互换创建跨链 HTLC(双边 HTLC 路径). 这个 FLOP腿必须活出反链腿(时锁对称,在链上强制), 这样 `timeoutBlocks` 是更长的腿和 `btcTimelockHours` 时间越短 USDT on (美国) TON/TRON则通过Near Intents定居——见 `docs/bridge/settlement.md`。 。 。 .

```typescript
await client.createCrossChainHtlc({
  agent: string,
  task: ComputeTask,
  rewardFlop: number,
  btcAddress: string,
  btcAmountSats: number | bigint,
  timeoutBlocks?: number,    // FLOP side, default 7200 (~2h)
  btcTimelockHours?: number, // counter-chain side, default 1
  hashLock?: string          // auto-generated if omitted
});
```

##### `checkHtlcStatus(hashLock)`

通过散列锁定查询 HTLC 状态 .

```typescript
await client.checkHtlcStatus('0x...');
// Returns: HtlcInfo | null (RPC fields include reward_amount and timeout_block)
```

##### `waitForSettlement(hashLock, timeoutMs?, pollIntervalMs?)`

Poll HTLC直到解决或暂停.

```typescript
await client.waitForSettlement('0x...', 30_000, 1_000);
// Returns: HtlcInfo with status SETTLED or REFUNDED, or null on polling timeout.
// null does not refund funds; reconcile the original HTLC before retrying.
```

##### `getBalance(address?)`

在 FLOP 令牌中获取账户余额 .

```typescript
await client.getBalance(); // Defaults to the connected account's SS58 address.
// Returns: string (human-readable FLOP, preserving decimal precision)
```

##### `submitPoUI(proofs, gnWeight, taskHash)`

提交经TEE验证的PoI证明批次.

```typescript
await client.submitPoUI(proofs, 1450, '0x...');
```

##### `getAccountInfo(address)`

获取账户信息,包括非ce和元数据.

```typescript
await client.getAccountInfo('flop1qyq...');
```

##### `getComputeTask(taskId)`

计算任务细节 .

```typescript
await client.getComputeTask('task_0x...');
```

##### `getTeeQuote(task)`

为计算任务获取 TEE 引用 .

```typescript
await client.getTeeQuote({ model: 'llama-3-8b', prompt: '...' });
```

### 代理钱包

创建和管理带有会话密钥的代理钱包 .

#### `createAgentWallet(api, signer, options)`

创建新代理钱包 .

```typescript
import { createAgentWallet } from '@flop-labs/sdk';

const walletTxHash = await createAgentWallet(client.api, client.signer, {
  agent: agentAddress, // Existing agent SS58 account, distinct from the owner.
  dailyCap: 100n * 10n ** 18n,
  perTxLimit: 5n * 10n ** 18n,
});
// Returns the transaction hash, not a wallet object.
```

#### `fundAgentWallet(api, signer, agent, amountRaw)`

从所有者账户中为代理钱包提供资金.

```typescript
import { fundAgentWallet } from '@flop-labs/sdk';

await fundAgentWallet(client.api, client.signer, agentAddress, 50n * 10n ** 18n);
```

#### `agentTransfer(client, fromWallet, toAddress, amount)`

在代理钱包之间转移资金.

```typescript
import { agentTransfer } from '@flop-labs/sdk';

await agentTransfer(client, 'flop1agent1...', 'flop1agent2...', 10.0);
```

#### `ownerWithdraw(client, walletAddress, amount)`

从代理钱包提取资金到所有者账户.

```typescript
import { ownerWithdraw } from '@flop-labs/sdk';

await ownerWithdraw(client, 'flop1agent...', 25.0);
```

#### `createSession(client, walletAddress, options)`

创建带有支出限制的会话密钥 .

```typescript
import { createSession } from '@flop-labs/sdk';

const session = await createSession(client, 'flop1agent...', {
  spendingLimit: 10.0,
  expiresAt: Date.now() + 3600000  // 1 hour
});
```

#### `executeViaSession(client, sessionKey, call)`

使用会话密钥执行呼叫 .

```typescript
import { executeViaSession } from '@flop-labs/sdk';

await executeViaSession(client, sessionKey, {
  pallet: 'htlc',
  method: 'create',
  args: { ... }
});
```

### x402 支付协议

X402 付款头的水电费.

#### `x402Fetch(url, options, paymentParams)`

用 x402 付款信头获取 .

```typescript
import { x402Fetch } from '@flop-labs/sdk';

const response = await x402Fetch('https://api.example.com/inference', {
  method: 'POST',
  body: JSON.stringify({ prompt: '...' })
}, {
  amount: 5.0,
  recipient: 'flop1qyq...'
});
```

#### `parsePaymentHeaders(headers)`

从响应中解析出 x402 付款信头 .

```typescript
import { parsePaymentHeaders } from '@flop-labs/sdk';

const payment = parsePaymentHeaders(response.headers);
```

### 命名的最小会话

`runDirectSession({ api, signer, miner, model, endpoint, prompt, maxFlop, maxTokens })` 在命名的矿工上打开一个频道,验证其身份并签名答复,以及 清算或收回代管. `maxFlop` 是生链单元; `maxTokens` 是一个正数 安全整数和默认值为256个完成符号。 请求带有这个限制 在受核实的收据约束的聊天信封中。 检查 `receipts[0].finishReason` 财务报告和审定财务报表 `completionTokens` 用于截取。 60秒轮值期限仍然有效; 更大的象征性预算不会延长。 分开解决等待频道 在提交付款前最后确定校准津贴。 合作执行和 最终发现的每个都有一个60秒的窗口 过期频道使用 暂停恢复。 如果结果不明,请保留频道ID并检查完成 重试前的频道状态和终端事件; 单独关闭的频道无法证明 成功解决。 零转出力在确认后即可失效 截止时间,且打开的频道在使用寿命后可以超时.

### 会话估计( 计算信道)

在打开前使用一个计算通道会话大小, 完全脱离链条, 使用链条本身的表 :

-   `computeChannel.estimateSession` 转换配置文件为 `G_n`,最小块,频道计数和代管.
-   `computeChannel.sessionPrior` 返回您尚未运行的任务的 P50/P90/P99 配置文件.
-   `computeChannel.calibrateSessionPrior` 符合你的模型和代理配置之前 大约10个探测器运行.
-   `computeChannel.reforecastSession` 更新中跑分数.

见 [届会估算指南](https://github.com/flop-labs/flop-core/blob/main/docs/sdk/session-estimation.md)。 。 。 .

### 反应钩 (可选)

```typescript
import { useFlopClient, useWalletBalance, useHtlcStatus } from '@flop-labs/sdk/react';

function MyComponent() {
  const client = useFlopClient('http://127.0.0.1:16111/rpc');
  const { balance } = useWalletBalance(client, 'flop1qyq...');
  const { status } = useHtlcStatus(client, '0x...');
  
  return <div>Balance: {balance} FLOP</div>;
}
```

## 类型

```typescript
interface ComputeTask {
  model: string;
  prompt: string;
  maxTokens?: number;
  temperature?: number;
}

type HtlcInfo = import('@flop-labs/sdk').HtlcInfo;

interface PoUISubmission {
  proofHash: string;
  gnMeasured: number;
  teeQuote: string;
  timestamp: number;
}

interface WalletInfo {
  address: string;
  balance: number;
  dailyLimit: number;
  dailySpent: number;
  allowedPallets: string[];
}
```

## 处理错误

```typescript
import { FlopClient, FlopError } from '@flop-labs/sdk';

let client: FlopClient | undefined;
try {
  client = await FlopClient.create({ endpoint: 'ws://127.0.0.1:9944', signer: '//Alice' });
  console.log(await client.health());
} catch (error: unknown) {
  if (error instanceof FlopError) {
    // Includes RUNTIME_INCOMPATIBLE raised while awaiting the connection factory.
    console.error(error.code, error.message);
  } else if (error instanceof Error) {
    console.error(error.message);
  } else {
    console.error('Unexpected error:', error);
  }
} finally {
  await client?.disconnect();
}
```

## 完整示例

这个来源的例子使用公众,众所周知 `//Alice` 仅在一次性键上 本地链条。 设定 `FLOP_AGENT_ADDRESS` 至代理人的SS58账户和 `FLOP_HTLC_TEE_REQUIREMENTS` 符合已登记考核要求 下面使用的模型。 使用私有的工作目录 。 HTLC 恢复文件只创建于之前 交易; 在出错时保留, 并在前核对其原散列锁 恢复,而不是重新运行 这个一次性设置。 永远不要登录其预想.

```typescript
import { writeFile } from 'node:fs/promises';
import { FlopClient, assertHtlcAppraisalProfile, createAgentWallet, fundAgentWallet } from '@flop-labs/sdk';

async function main() {
  const agentAddress = process.env.FLOP_AGENT_ADDRESS;
  const teeRequirements = process.env.FLOP_HTLC_TEE_REQUIREMENTS;
  if (!agentAddress || !teeRequirements) throw new Error('Set the agent address and registered HTLC appraisal requirements');
  const client = await FlopClient.create({ endpoint: 'ws://127.0.0.1:9944', signer: '//Alice' });
  try {
    await assertHtlcAppraisalProfile(client.api, teeRequirements);
    const { preImage, hashLock } = FlopClient.generateSecrets();
    await writeFile('htlc-purchase.json', JSON.stringify({ preImage, hashLock }) + '\n', { flag: 'wx', mode: 0o600 });

    const FLOP = 10n ** 18n;
    const walletTxHash = await createAgentWallet(client.api, client.signer, {
      agent: agentAddress,
      dailyCap: 100n * FLOP,
      perTxLimit: 5n * FLOP,
    });
    console.log('Wallet creation transaction:', walletTxHash);
    await fundAgentWallet(client.api, client.signer, agentAddress, 50n * FLOP);

    // This direct HTLC uses the owner's balance, separately from the agent wallet.
    const htlc = await client.createHtlc({
      agent: agentAddress,
      task: { model: 'llama-3-8b', prompt: 'Analyze BTC price trend', tee_requirements: teeRequirements },
      rewardFlop: 5.0,
      timeoutBlocks: 60,
      hashLock,
    });
    console.log('HTLC created:', htlc.htlcId);

    const settlement = await client.waitForSettlement(hashLock, 30_000, 1_000);
    if (settlement?.status === 'SETTLED') {
      console.log('Node reports settlement:', settlement.miner, settlement.gn_used);
    } else if (settlement?.status === 'REFUNDED') {
      console.log('Node reports a refund; confirm finality before treating it as complete');
    } else {
      console.log('Unconfirmed: polling timed out without a refund. Keep the original intent and reconcile chain state');
    }
  } finally {
    await client.disconnect();
  }
}

main().catch(console.error);
```

## 发展

```bash
# Install dependencies
npm install

# Build the SDK
npm run build

# Watch mode
npm run dev

# Clean build artifacts
npm clean
```

## 许可证

Apache-2.0 FLOP网络

## NVIDIA GPU 运算符

关于经营NVIDIA GPU的矿工获得奖励,请参见完整指南:

-   **[在 GPU 主机上运行 FLOP 矿工](https://ask.flop.finance/docs/run-miner)** - 采矿设置和工作流程
-   [将您的 GPU 操作 FLOP](https://ask.flop.finance/docs/run-gpu-provider) - GPU所有者新密码的普通语言启动

GPU 操作器的快例 :

```typescript
import { FlopClient, type TeeQuote } from '@flop-labs/sdk';

// Connect as miner
const client = await FlopClient.create({ 
  endpoint: 'ws://127.0.0.1:9944',
  signer: '//Miner'
});

// Monitor for HTLCs
const htlc = await client.checkHtlcStatus(hashLock);
if (htlc && htlc.status === 'CREATED') {
  // Execute inference on NVIDIA GPU
  const result = await executeOnGpu(htlc.task); // Your GPU execution logic
  
  // Generate TEE quote
  const teeQuote: TeeQuote = {
    version: '1.0',
    miner_address: client.address,
    task_reference: {
      htlc_hash_lock: htlc.hashLock,
      model_hash: `sha256:${htlc.task.model}`,
      task_timestamp: Math.floor(Date.now() / 1000),
    },
    compute_output: {
      gn_weight: result.gnWeight,  // G_n weight (BFLOPs)
      execution_time_ms: result.executionTime,
      encrypted_result: result.encryptedOutput,
    },
    attestation: {
      tee_type: 'NVIDIA_HOPPER_CC',  // or 'NVIDIA_RUBIN_CC', 'CPU_WRAPPED_TEE'
      hardware_pubkey: hardwarePubkey,
      quote_hex: teeQuoteHex,
      signature: minerSignature,
    },
  };
  
  // Redeem HTLC with TEE quote
  const txHash = await client.redeemHtlc(
    htlc.htlcId,
    preImage,
    teeQuote,
  );
  console.log('✓ HTLC redeemed:', txHash);
  
  // Submit PoUI proof batch (optional, for additional rewards)
  const proofs = generateStarkProofs(result);
  const taskHash = generateTaskHash(htlc);
  const proofTxHash = await client.submitPoUI(proofs, result.gnWeight, taskHash);
  console.log('✓ PoUI proof submitted:', proofTxHash);
}
```

### TEE 引文格式

```typescript
interface TeeQuote {
  version: string;           // "1.0"
  miner_address: string;     // flop1... address
  task_reference: {
    htlc_hash_lock: string;  // HTLC identifier
    model_hash: string;      // sha256:model...
    task_timestamp: number;  // Unix timestamp (seconds)
  };
  compute_output: {
    gn_weight: number;       // G_n weight (BFLOPs)
    execution_time_ms: number;
    encrypted_result: string; // 0x... encrypted output
  };
  attestation: {
    tee_type: string;        // "NVIDIA_HOPPER_CC" | "NVIDIA_RUBIN_CC" | "CPU_WRAPPED_TEE"
    hardware_pubkey: string; // 0x... hardware public key
    quote_hex: string;       // 0x... raw TEE quote
    signature: string;       // 0x... miner signature
  };
}
```

### 支持的TEE类型

| TEE 类型 | 硬件 | 生产准备 |
| --- | --- | --- |
| `NVIDIA_HOPPER_CC` | H100, H200 (韩语) | 对 |
| `NVIDIA_RUBIN_CC` | B100, B200 (英语) | 对 |
| `CPU_WRAPPED_TEE` | RTX 4090+ + AMD SEV/英特尔 TDX | 只有测试网 |

### TEE 验证

TEE桥的引文为:

-   **时间戳新鲜度 :** 引用必须 < 60秒
-   **签名核查:** 验证矿工签名
-   **重放保护 :** 跟踪任务散列,防止双重开支
-   **硬件验证 :** 对照登记册检查硬件密钥( 只生产)

```typescript
import { verifyTeeQuote, type PouiPayload } from '@flop-labs/sdk/tee';

const bridge = new TeeBridge({ simulatorMode: false });

// Register known hardware keys (production)
bridge.registerHardwareKey('0x...');

// Verify TEE quote
const payload: PouiPayload = parseTeeQuote(quoteJson);
const result = await bridge.verify(payload);

if (result.valid) {
  console.log(`✓ TEE verified: ${result.gnWeight} G_n`);
} else {
  console.error(`✗ Verification failed: ${result.error}`);
}
```

完整的设置指令、硬件要求和生产部署指南:

-   **[在 GPU 主机上运行 FLOP 矿工](https://ask.flop.finance/docs/run-miner)** - 生产设置和工作流程
-   **[将您的 GPU 操作 FLOP](https://ask.flop.finance/docs/run-gpu-provider)** - GPU所有者的普通语言启动:硬件、账户、存款、访问

## 链接

-   [FLOP 文档](https://ask.flop.finance/docs/what-is-flop)
-   [运算符配置和 RPC 引用](https://ask.flop.finance/docs/operator-config-reference)
-   [代理账户和开支控制](https://ask.flop.finance/docs/agent-accounts-and-spend-control)

## 常见问题

### @flop-labs/sdk 是什么？

FLOP 网络的 TypeScript SDK – HTLC 工作流程、 PoUI 证明和账户管理

### 如何安装 @flop-labs/sdk？

在项目目录运行 npm install @flop-labs/sdk，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 flop-client-gen，可以用 npx flop-client-gen 直接运行。

### @flop-labs/sdk 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @flop-labs/sdk 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @flop-labs/sdk 可以商用吗？

@flop-labs/sdk 使用 MIT OR Apache-2\.0 许可。可在 MIT、Apache-2\.0 中任选其一遵守。选择 MIT 时，宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @flop-labs/sdk 的下载量有多少？

根据 npm 官方下载统计，@flop-labs/sdk 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,449 次，日均约 115 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @flop-labs/sdk 还在维护吗？

最新版本 0\.6\.0 发布于 2026/11/12（3 天前）；至今共发布 5 个版本，其中过去 12 个月发布了 5 个；首次发布于 2026/10/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

