[ Lay2 Community Bounty 0x01 ] Proposal (with a 50,000 CKB bonus) for Adapting PW-Core to Back-end Usage

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 the sign 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.

10 Likes

I will personally also donate 50000 CKB to anyone successfully built the above components per zhixian’s requirements.

5 Likes

I am holder ckb in indodax sir

Chinese reply 1:

Chinese reply 2:

Maybe there are 3 solutions for IndexerCollector?

  1. use axios.post directly
  2. use RPC class and related classes in ckb-js-toolkit
  3. use CKBRPC in @nervosnetwork/ckb-sdk-core
1 Like

I have tried to implement a version of RawProvider and IndexerCollector

Here is the sample code

const {
  default: PWCore,
  AddressType,
  Address,
  Amount,
  DefaultSigner,
  Blake2bHasher,
} = require('./build/main');
const { RawProvider } = require('./build/main/providers/raw-provider');
const { SimpleBuilder } = require('./build/main/builders/simple-builder');
const {
  IndexerCollector,
} = require('./build/main/collectors/indexer-collector');

async function main() {
  const pw = new PWCore('https://aggron.ckb.dev');
  await pw.init(
    new RawProvider(
      '0xprivate key'
    ),
    new IndexerCollector()
  );

  const builder = new SimpleBuilder(
    new Address(
      'ckt...',
      AddressType.ckb
    ),
    new Amount('100')
  );

  const tx = await builder.build();

  const signer = new DefaultSigner(PWCore.provider);
  signer.hasher = new Blake2bHasher();

  const txHash = await pw.sendTransaction(tx, signer);

  console.log(txHash);
}

main();
2 Likes

Summy for this proposal

Several days ago, we post this proposal and offered 50,000 CKB for any one who successfully completes the quests and creates an acceptable PR to our github repo, and XueJie offerred another 50,000 as bonus. By far, we have received 3 submissions. The first two were directly posted here, and the last two were proposed as PR to our repo. After evaluating all three submissions, we decide to choose Wen Chao’s solution, and everyone can see the efforts made by all three developers, thank you all for your contribution!

We contacted Wen Chao @huwenchao to discuss the reward, and he generously left the 50,000 CKB to the future community incentive plan. We were also very encouraged, so we decided to name this event Lay2 Community Bounty 0x01. We will continue to release bounties suitable for community participation to encourage the growth of the Nervos developer community. For the other two developers, we prepared 5,000 CKB as well as a COFFEE token as rewards for your efforts and participation. Please contact me through pm for follow up process @taurenshaman @homura.

We have published the alpha.6 version of pw-core on npm which contains the new components, and corresponding source is in the dev branch. If you have any questions about adapting pw-core in the backend, please leave messages here and we will respond as soon as possible.

5 Likes

Congrats and many :heart: :heart: :heart: to @huwenchao @taurenshaman @homura and Lay2 team!

I’d be happy to donate 50000 CKB personally to Lay2 Community Bounty fund. Let me know @zhixian

5 Likes

We are honored! It feels like a ckb-gitcoin is on the way :sunglasses:
Next time we release a bounty, we can work out a plan about how to match donations from other community members. Looking forward to it!

3 Likes