A GraphQL layer for CKB

A Quick Glance

Below is an example that demonstrates how to use GraphQL playground to interact with the CKB testnet. Thanks to the GraphQL ecosystem, we can easily try out the GraphQL layer through Vercel.

GraphQL Playground Example

view the above query
query Block {
  block {
    header {

    transactions {
      inputs {
        cellOutput {

          lock {


      outputs {

        lock {


I have also created a super lightweight explorer to showcase the usage. You can access it online at https://ckb-urchin.vercel.app (currently, only the transaction view is supported). This demonstration highlights that the GraphQL layer can function without needing an additional server, allowing us to utilize the layer directly within the browser.

The explorer is also compatible with your own devnet. Simply modify the urchin-config in the browser’s local storage to {“url”:“https://localhost:8114”,“network”:“ckb_testnet”}.


This project aims to address several challenges, including:

  • Connecting CKB dApps with GraphQL to enhance the dApps ecosystem.
  • Sharing knowledge efficiently, as I have frequently encountered recurring questions like “How to find a block of a transaction” or “How to find a transaction of a cell.”
  • Simplifying the process of connecting various pieces of data, which can be complex and unintuitive with JSON RPC.
  • Automating the handling of RPC requests, such as batch requests, to free from manually scheduling requests.
  • Find a good practice for building custom indexers


GraphQL offers many benefits, such as self-documenting, strongly typed, and most importantly, it can be used to build a data mesh, which means we can reach some related data through a single request, such as resolving an OutPoints to a cell or a DepGroup to its cell and deriving its data hash or type hash. GraphQL can also help us learn the relationships between each piece of data.

Furthermore, GraphQL has a huge community which means there are through of reusable components available and good practices, such as IDE plugins, SDKs, and design patterns.

If you find these interesting ideas, please let me know, such as

  • Creating a module to help integrate the GraphQL layer to the js projects as an alternative to interacting with RPC
  • Developing a lightweight explorer that is compatible with the local devnet
  • Expanding functionality to support custom indexers and integration with other mature programs like Prisma

Love this bro, I suffered a lot when I tried to retrieve data with RPC API.

I’ve got no idea what any of this means :laughing: But thanks for your hard work!

1 Like

It looks cool, I am thinking of combining GraphQL and chatgpt so that we can build a tool to help developers retrieve on-chain data.

I took a look at the code of ckb-urchin, it seems that it still needs to use CKB PRC to get the latest transactions. It would be even better if support for transactions, I’m not sure why it hasn’t been implemented.


it seems that it still needs to use CKB PRC to get the latest transactions

You’re right, the ckb-graphql is still based on the RPC, it’s just an alternative to the RPC. The intention of ckb-graphql is to

  • connect pieces of data
  • eliminate the need to coordinate the batch of RPCs manually
  • help to understand the relationship between Script, Cell, Input, Output, CellDep, Transaction, and Block through the GraphQL ability

Therefore, I avoid introducing additional states in this layer. Just to clarify, the ckb-graphql tool is not a replacement for RPC, but rather an alternative means of accessing data.

To achieve this, it’s important to avoid introducing additional states into this layer. Doing so would require a full node with sync and a persistence layer, which would increase the complexity of the architecture.

It would be even better if support for transactions

Good suggestion, I’ll support the transactions with the indexer features