← 所有集成在 GitHub 查看源代码 →
Tier 2 — Full Deakee partner
SDK
Any Node.js app (Express, Fastify, Hono, …)
For custom stacks, headless setups, or anything that doesn't fit a packaged plugin. Provides the canonical centralized-loyalty primitives (member balances, transaction log, refund clawback) plus the relayer client for bridging on-chain.
npm
npm install @deakee/loyalty-sdk两种集成模式
同一插件代码支持两种模式。今天先以 OAuth2 模式启动;日后通过配置切换加入桥接层 — 无需数据迁移。
OAuth2 模式
计划中你的数据库中维护中心化忠诚度,通过 OAuth2 同步到 Deakee。不上链、不进交易所 — 但客户可在 Deakee 中查看余额,你可接受 Deakee 凭证。
- 对接当前的 deakee.com/api/oauth/* 后端。
- 无代币、无作为发行者的法律风险。
- 通过配置切换即可升级到桥接模式。
桥接模式
计划中部署 ERC-8063 合约;客户可将中心化余额铸造为链上代币,并在 Deakee 交易所交易。
- 增加交易所上市和跨品牌兑换。
- 需要 Deakee 中继器(尚未发布)。
- 与 OAuth2 模式同一套插件代码 — 准备好时再启用。
安装
- npm install @deakee/loyalty-sdk
- Run the published migrations against your DB to create the loyalty tables.
- Use members.credit() in your order-complete logic; bridge.withdraw() from your customer-account UI.
- Mount the identity OAuth callback route so customers can link their Deakee wallet.
示例
import { DeakeeLoyalty } from "@deakee/loyalty-sdk";
const loyalty = new DeakeeLoyalty({
apiKey: process.env.DEAKEE_API_KEY,
contractAddress: process.env.DEAKEE_CONTRACT,
db: myKnexInstance,
});
// Centralized earn:
await loyalty.members.credit({
userId, points: 50, reference: `order_${id}`,
});
// User-initiated bridge to chain:
await loyalty.bridge.withdraw({ userId, amount: 500 });Deakee 如何连接到你的插件
你的合作伙伴 API 密钥用于向 Deakee 中继器认证调用。OAuth2 authorize/token URL 每个客户使用一次,用于获取钱包地址(范围:仅 identity)。
| authorize_url | https://deakee.com/oauth2/authorize (scope=identity) |
| token_url | https://deakee.com/oauth2/token |
| api_base_url | https://deakee.com/api/relayer/v1 |
验证合规性
上线前,针对你的部署运行官方一致性验证器。它会检查中心化账本、identity OAuth 流程、桥接铸造/销毁连接以及幂等性。
npx @deakee/loyalty-verifier \
--partner-api-key <your key> \
--plugin-url <your plugin URL> \
--contract-address <your ERC-8063 contract> \
--test-user-email test@example.com遇到问题?阅读完整的 README 或在 github.com/deakee/loyalty/issues 提交 issue。