@ cloakely/ sdk (英语)
类型脚本 SDK 衣着公平发射 以及基内迪克的私人交易 极乐。 。 。 .
发射
- 密封-有价信使的发射,Bots不能前跑.
- 每个人都要付一个清场价.
- 发射池以那个价格播种.
私营贸易
- 盾牌余额:买入,卖出,发出并批量交易发射信使,不出现钱包.
- 零知识证明是在用户设备上作出的.
- 中继器提交交易,但无法更改.
在极乐测试网(链)上直播 99801) (中文(简体) ). 建造在 维姆。 。 。 .
npm install @cloakely/sdk viem
发射
import { createPublicClient, createWalletClient, custom, http, parseEther } from "viem";
import { Cloak, deploymentFor, elysiumTestnet, legacyFactories } from "@cloakely/sdk";
const d = deploymentFor(elysiumTestnet.id);
const publicClient = createPublicClient({ chain: elysiumTestnet, transport: http() });
const walletClient = createWalletClient({ chain: elysiumTestnet, transport: custom(window.ethereum) });
// earlier factories too, so every launch lists, settles and pays out
const cloak = new Cloak(publicClient, walletClient, d.factory, legacyFactories(d));
// a project or launchpad: a sealed-bid launch. At settlement it opens a Uniswap V2 pool (token / WHYPE) at the
// clearing price, with the LP burned ("burn") or locked until a date
const now = Math.floor(Date.now() / 1000);
const { auction } = await cloak.createLaunch({
name: "Shade", symbol: "SHADE",
saleSupply: 1_000_000n * 10n ** 18n,
minPrice: 10n ** 12n, tickSize: 10n ** 12n, numTicks: 100,
commitEnd: now + 3600, revealEnd: now + 3600 + 600,
lpBps: 5000, lpLockUntil: "burn",
});
// a bidder: hashed, timelock-encrypted to the drand round when bidding ends, deposit rounded up to a bucket
await cloak.bid(auction, { maxPrice: parseEther("0.00002"), quantity: parseEther("10000") });
// anyone (usually the hosted keeper)
await cloak.revealAll(auction);
await cloak.settle(auction);
await cloak.claimAll(auction);
await cloak.payOut(auction); // the creator's proceeds, and the launch fee to the treasury
const s = await cloak.getAuction(auction);
s.uniPair; // the Uniswap V2 pool, tradable and trackable anywhere (zero for launches before Nov 2, which use a CloakPair)
s.pair; // the market Cloak's private router and batcher trade: a CloakV2Market in front of that pool
私营贸易
import { CloakPrivate, deploymentFor, elysiumTestnet, loadProver, relayerSubmitter } from "@cloakely/sdk";
const d = deploymentFor(elysiumTestnet.id);
const keys = await CloakPrivate.keysFromWallet(walletClient, { chainId: d.chainId, verify: true });
const priv = new CloakPrivate(
publicClient, d.router, keys,
() => loadProver(d.circuitsUrl), // 12 MB of circuit files, fetched once and hash-checked
relayerSubmitter(d.relayerUrl), // the relayer submits, so the wallet never appears
d.vaultsBlock!, d.batcher, d.migrator, // notes are scanned from the permanent vaults' first block
);
await priv.loadMarkets();
await priv.shieldHype(walletClient, parseEther("1")); // the one public step
await priv.buy(token, parseEther("0.25")); // private buy through the launch's Uniswap pool
await priv.batch(token, "buy", parseEther("0.37")); // batch round: trade size hidden too
await priv.send(token, "cloak:…", parseEther("100")); // private transfer: amount hidden
await priv.unshieldHype(freshAddress, parseEther("0.5")); // back to any wallet
console.log(await priv.balance(priv.hypeMarket.pool)); // only this account can see it
二等兵USDC住在自己的金库里 从部署中注册,然后屏蔽, 发送和撤退像任何标志:
const usdc = priv.addAsset(d.assets![0]); // { symbol: "USDC", decimals: 6, … }
await priv.shieldToken(walletClient, usdc.token, parseUnits("50", 6)); // approve + deposit (public, once)
await priv.send(usdc.token, "cloak:…", parseUnits("20", 6)); // amount hidden
await priv.unshieldToken(usdc.token, freshAddress, parseUnits("10", 6)); // 0.25% fee kept
从11月2日的发射, 将私人余额保存在一个共享的发射库(测试网实验)中。 有一个 私人发送甚至没有显示移动了哪个令牌:其中继器在同一交易中由您的私人 HYPE 支付.
const shared = new SharedVaultClient(
priv, d.shared!, d.sharedRouter!,
() => loadSharedProver(d.circuitsUrl), // its own circuit (the token is inside each note), hash-checked
sharedRelayerSubmitter(d.relayerUrl), d.sharedBlock,
);
await shared.buy(token, parseEther("0.25")); // private HYPE → private token, through the Uniswap pool
await shared.send(token, parseEther("100"), "cloak:…"); // amount, parties and the token itself hidden
await shared.sell(token, parseEther("50")); // back to private HYPE
await shared.unshield(token, parseEther("10"), freshAddress);
console.log(await shared.balances()); // every token this account holds there
私人账户来自一个仅与链条相连的EIP-712签名(绝不是合同),所以它和 cloak: 地址永远不变。 同一个钱包总是可以恢复它,服务器上没有存储任何东西. 在节点,你自己读回路文件,然后传给 createProver(wasm, zkey)。 。 。 .
NFT投放和WL即时销售
import { CloakDrops, CloakSpots, deploymentFor, elysiumTestnet, parseEther } from "@cloakely/sdk";
const dep = deploymentFor(elysiumTestnet.id);
const drops = new CloakDrops(publicClient, walletClient, dep.dropFactory!, dep.dropFactoryBlock);
const { drop } = await drops.create({ name: "Moonfoxes", symbol: "MOON", baseURI: "", supply: 1000, floor: parseEther("0.5"),
gtd: { list: [{ wallet: "0x…", spots: 2 }], price: parseEther("0.4"), durationSecs: 86400 },
wl: { list: ["0x…"], boostBps: 2000 }, biddingSecs: 86400 });
await drops.bid(drop, { price: parseEther("0.7"), quantity: 1 }); // sealed to a drand round; WL wallets pass wl: true
await drops.claim(drop, bidId); // or claimTo(drop, bidId, freshWallet)
// sell a partner collection's WL spots: winners name the wallet to whitelist
const spots = new CloakSpots(drops, dep.spotBook!);
const sale = await spots.create({ name: "Moonfoxes WL spots", symbol: "MOONWL", supply: 5, floor: parseEther("0.5"), biddingSecs: 86400, partner: "Moonfoxes" });
await spots.setWallets(sale.drop, bidId, ["0x…"]); // one per spot won, until the deadline
const csv = CloakSpots.csv(await spots.winners(sale.drop)); // the list for the partner
创作者的价格是地板. 投标按价格排名(WL投标按价格×(1+助推)),每个中标者支付一笔结算费 价格(WL赢家付1分加1分加1分加1分加1分加1分加1分加1分加1分加1分加1分加1分) 一旦开标就马上解决 每一出价都必须包括一个NFT在会场上;一个出价仍然被封在最后 显示窗口损失10%.
收费(测试网β)
| 行动 | 收费 |
|---|---|
| 存款和私人汇款 | 免费 |
| 退款、私人互换和批发订单 | 0.25% 妇女 |
| 成功发射 | 1.5%的加薪 |
| 更新 | 中继器的气体加一个比值,在证明内支付 |
规则存在于链上 CloakConfig,而任何Cloak合同中的功能都不能移动用户资金. Testnet仍在设置中,因此所有者可以一次性地(在1%和3%的硬上限内)更改收费和上限;一旦设置结束,在主网之前,提高收费或上限等公众3天的延迟. 每一个规则的号码: 文档/RULES.md。 。 。 .
出口
| 导出 | 这是什么 |
|---|---|
Cloak | 发射: createLaunch, (中文(简体) ), bid, (中文(简体) ), revealAll, (中文(简体) ), settle, (中文(简体) ), claimAll, (中文(简体) ), payOut, (中文(简体) ), getAuction, (中文(简体) ), listLaunches |
CloakPrivate | 私人结余: shieldHype, (中文(简体) ), shieldToken, (中文(简体) ), buy, (中文(简体) ), sell, (中文(简体) ), batch, (中文(简体) ), send, (中文(简体) ), unshieldHype, (中文(简体) ), unshieldToken, (中文(简体) ), addAsset, (中文(简体) ), balance, (中文(简体) ), maxSpendable, (中文(简体) ), migrateFrom |
CloakDrops | 密封的 NFT 滴出 : create, (中文(简体) ), get, (中文(简体) ), details, (中文(简体) ), listed, (中文(简体) ), gtdMint, (中文(简体) ), bid, (中文(简体) ), bids, (中文(简体) ), revealAll, (中文(简体) ), settle, (中文(简体) ), claim, (中文(简体) ), claimTo, (中文(简体) ), claimAll, (中文(简体) ), withdrawRefund, (中文(简体) ), payOut, (中文(简体) ), mintUnsold |
CloakSpots | WL现货销售: create, (中文(简体) ), open, (中文(简体) ), sale, (中文(简体) ), sales, (中文(简体) ), winners, (中文(简体) ), setWallets, (中文(简体) ), CloakSpots.csv |
relayerSubmitter, (中文(简体) ), walletSubmitter | 如何通过中继器(私人)或钱包(测试)提交私人电话 |
loadProver, (中文(简体) ), createProver | 在设备上运行的 Groth16 验证器 |
deployments, (中文(简体) ), deploymentFor | 每个链条的地址、启动块、中继器和线路 URL |
elysiumTestnet | 连锁店 |
*Abi, (中文(简体) ), @cloakely/sdk/bytecode | 合同 ABIs 和字节代码 |
文档 : 外衣. boblabs.tech/docs来源和合同: github.com/NECOKIZZ/cloak (韩语)未审计的测试网软件。 麻省理工学院有执照.