Background
PW-Core (github) is designed as a front-end sdk. With pw-core you can use various crypto wallets directly as CKB wallets. Besides, we provide a lot of friendly models and a more natural way to build your transactions. If you are new to CKB dApp development, be sure to try out pw-core (you can start with our payment demo).
Recentlly we received demands for using pw-core in back-end development to get an unified experience for dApp developers, which we also think is a good idea. However we are short of engineers ourself, and don’t have time for the adaption. So we come up a proposal for adding extra components to pw-core for back-end usage.
RawProvider
In back-end development, if developers ever need to sign a transaction with their own key, it must be done automatically. So the provider we need is just the most basic one which allows importing a private key and is able to sign transactions. We call it RawProvider
. The implementation of RawProvider may be like this:
- Pass a private key string in the
constructor
; - Implement CKB’s default signature method (with the built-in
Blake2bSigner
) in thesign
method;
That’s it, not so difficult right?
IndexerCollector
Another missing piece is a collector based on the official ckb-indexer.
Currently the default collector in pw-core is PwCollector
, which is based on Portal Wallet’s backend server. It’s not a good choice for developers to depend your dApp’s data service on other project’s backend, but it’s also very expensive to build a server to cache and analyze CKB’s transactions. So the best solution is building a collector which adapts the public ckb-indexer services.
To build the IndexerCollector
, you need to read the ckb-indexer’s rpc method and adapt them into Collector’s interfaces. You can refer to the implementation of the built-in PwCollector as well as SUDTCollector.
Bonus from Lay2
To add some incentives for you to start your CKB adventure, we offer 50,000 CKB (500 USD for now, maybe a Tesla Model Y in the near future :P) for anyone who can implement those two components and get your PR accepted by our dev team. And of course, if you have any questions, feel free to post them here, and we’ll also invite you into our chat group for more instant support.