用途
genesis-token 用于验证用户是否拥有 Seeker 设备。其核心方式是确认用户持有 Seeker Genesis Token(SGT)——一种每台 Seeker 设备唯一铸造一次的 NFT。
主要能力
- 将专属内容限制给已验证的 Seeker 所有者
- 分发设备专属奖励
- 实现防女巫攻击保护(防止重复领取)
- 验证真实的 Seeker 设备所有权
使用方式
前置条件
- 已完成 MWA 设置(用户能够连接钱包)
- 用于验证的后端服务器(SGT 检查必须在服务端进行)
- 用于 RPC 查询的 Helius API 密钥
两步验证流程
- 使用 Sign-in-with-Solana(SIWS)证明用户拥有该钱包
- 检查钱包中是否包含 Seeker Genesis Token
实现步骤
步骤 1:客户端 - 签名 SIWS 载荷
import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
const APP_IDENTITY = {
name: 'Your React Native dApp',
uri: 'https://yourdapp.com',
icon: 'favicon.ico',
};
async function signSIWSPayload() {
const result = await transact(async (wallet) => {
const authorizationResult = await wallet.authorize({
cluster: 'solana:mainnet',
identity: APP_IDENTITY,
sign_in_payload: {
domain: 'yourdapp.com',
statement: 'Sign in to verify Seeker ownership',
uri: 'https://yourdapp.com',
},
});
return {
walletAddress: authorizationResult.accounts[0].address,
signInResult: authorizationResult.sign_in_result,
};
});
return result;
}
步骤 2:后端 - 验证 SIWS 签名
import { verifySignIn } from '@solana/wallet-standard-util';
async function verifySIWS(signInPayload, signInResult): Promise<boolean> {
const serialisedOutput = {
account: {
publicKey: new Uint8Array(signInResult.account.publicKey),
...signInResult.account,
},
signature: new Uint8Array(signInResult.signature),
signedMessage: new Uint8Array(signInResult.signedMessage),
};
return verifySignIn(signInPayload, serialisedOutput);
}
步骤 3:后端 - 检查 SGT 所有权
完整验证脚本参见 references/sgt-verification.md。
步骤 4:后端 - 合并两项检查
async function verifySeekerUser(signInResult) {
// Verify SIWS signature
const siwsVerified = await verifySIWS(signInResult);
// Check SGT ownership
const hasSGT = await checkWalletForSGT(signInResult.walletAddress);
// If both true, user is a verified owner of a Seeker device
return siwsVerified && hasSGT;
}
后端依赖
npm install @solana/wallet-standard-util @solana/web3.js @solana/spl-token
适用场景
- 需要将内容或功能限制给 Seeker 设备持有者的应用
- 需要向 Seeker 设备持有者分发专属奖励的场景
- 需要防止同一用户重复领取的防女巫攻击场景
- 需要验证真实 Seeker 设备所有权的场景
限制
- SGT 检查必须在服务端进行,不能仅在客户端完成
- 需要 Helius API 密钥用于 RPC 查询
- 需要已完成 MWA 设置,用户能够连接钱包
- 需要后端服务器支持验证流程
外部文档
- Detecting Seeker Users: https://docs.solanamobile.com/react-native/detecting-seeker-users
- Phantom SIWS Spec: https://github.com/phantom/sign-in-with-solana