A simple Airdrop demo

CKB is very flexiable consider its programing model and how things usually works. But from the very past, I feel like there is a preference of discussing less simple out-of-box solution than taking complex underlying perfect technical debates. If we want to build a ecosystem with impact, I believe it’s worth to post more naive(even stupid) but specific solution than discuss imaginable perfect tech. Because the former is more direct for testing ideas.

That’s why I built a demo project called join-airdrop. The smart contract is a simple airdrop-lock that requires users to join first in order to get airdrop for a specific UDT token. In cell model, doing a airdrop requires paying extra CKBytes to the receiver to help them receive the UDT tokens. with the join-airdrop, the users prepare their own Cell to receive UDT solving such a problem.

Compare to this contract, the AnyOneCanPay is a more general and maybe more powerful solution on such a problem, but this serves as a simple, naive and out-of-box solution specific for such an use case.

Repo: GitHub - RetricSu/join-airdrop: a simple airdrop-lock contract that requires users to join first in order to get airdrop for a specific UDT token
Preview: https://join-airdrop-app.vercel.app/

P.S. the smart contract and the app is all built using Typescript, so it should be pretty easy to understand.

————————
中文版:

CKB 在编程模型和做东西的原理上非常灵活。但长期以来,我感觉似乎有一种不自觉的倾向是更多地去讨论底层某种技术方案的完美性,而比较少去讨论简单的开箱即用方案。

如果我们想打造一个真正有影响力的生态,我认为多提一些简单(甚至有点蠢)但具体的方案,比空谈想象中的完美技术方案更有价值。因为前者更方便测试想法。

所以我做了一个叫 join-airdrop 的 demo 项目。这个合约很简单,是一个"注册式空投"的 lock:用户必须先加入,才能领取特定 UDT 代币的空投。

在 CKB 的 cell 模型中,做空投的项目方需要为接收方支付额外的 CKBytes,好让用户能收到 UDT 代币。而 join-airdrop 让用户自己准备 Cell 来接收 UDT,解决了这个问题。

相比这个合约,AnyOneCanPay 是一个更通用、可能也更强大的解决方案,但 join-airdrop 提供了一个简单、可能有点幼稚、但开箱即用的方案,专门用于这种场景。

仓库:GitHub - RetricSu/join-airdrop: a simple airdrop-lock contract that requires users to join first in order to get airdrop for a specific UDT token
在线预览:https://join-airdrop-app.vercel.app/

P.S. 整个合约端和前端都是用 typescript 写的,所以应该很容易看懂,不需要懂 rust 就能动手。

10 Likes

Cool,这个demo确实很有用。不过我有点疑问/建议:
1、似乎 demo 里面没有使用xUDT,而是sUDT,这是出于什么考虑?生态上对sUDT的支持并不是很友好,如果我们推荐xUDT,那我们的 Demo 是不是可以尽可能使用xUDT,以免开发者再去做从sUDT转到xUDT的工作。

2、不知道我这笔交易是否符合预期:https://testnet.explorer.nervos.org/transaction/0xb7e94961f39dc929d804c30fae134f93d3b2341b1afae293ca2461f5e3e4bcc9

3、如果demo页面上附上一些demo的背景、简单的使用说明,我想更利于开发者理解demo,参考:CKB Next APP

1 Like

好建议,这几个问题都是因为做得比较粗糙,我改一改

1 Like

更新了,可以再试试。

  1. 使用 xudt 而不是 sudt
  2. 修复了合约没有验证 udt type script hash 的 bug,现在只有 owner 可以分发 udt 给接受空投的 cell
  3. 增加了 about 页面解释 demo 合约的原理
2 Likes