[Klaytn] New JSON-RPC api to get multi blocks

Klaytn blockchain is one of the blockchains with the fastest block production rate, making it a very convenient blockchain to transfer coins. But besides that, it also makes block analysis faster to catch up

I known currently there is no API that supports get multi blocks at one time. I’m currently trying to detect Klay coin deposit transaction to our system by using getblocknumber API and ThreadPool to get scan concurrency 100 blocks per time and it took around 60 second to get response and analysis.

I’m looking for a new JSON-RPC api getblockNumbers(from, to) as similar as ethGetLogs(fromBlock, toBlock) to query multi blocks information to make process faster.

Please comment with your thought, Thanks in advance!

Hi @tobilova ,
Thank you for your interest in Klaytn.

Klaytn supports klay_getLogs. We are trying to support all APIs from Ethereum. You can simply substitute eth to klay in API name.

I didn’t understank your saying :

I’m currently trying to detect Klay coin deposit transaction to our system by using getblocknumber API and ThreadPool to get scan concurrency 100 blocks per time and it took around 60 second to get response and analysis.

Does this mean it took 60 seconds for calling getblocknumber 100 times?

1개의 좋아요

Does this mean it took 60 seconds for calling getblocknumber 100 times?

Yes correctly, but that is concurrency calling. If I call sequentially, it can go up to 80-90 seconds (query and analysis). I would like to call only ONE single request to query data of multi blocks by input block range.

It is interesting that it takes more time for concurrent calls. I will take a look why it takes longer.

If you are querying for the old data, it could take a long time. The chain data is getting bigger every time and the searching on a huge DB takes time. Our team is trying to enhance the read speed in every way.
If you call on the recent blocks, it will take a short time. (Since it is just created and all data is cached.)

Using klay_getLogs or klay_getFilterLogs is one way to implement.
Another way you could try is to use KAS. KAS is allocating information about the chain data in its own DB. It looks like the data about token and NFT is allocated, if this is what you are looking for. (Check out Token Information) If you are interested in KAS, I can check with the KAS team about the relevant API.

1개의 좋아요

Yes, but AFAIK, klay_getLogs and klay_getFilterLogs are used for getting of smart contract token events (Which I don’t need). I just want to query Klay coin transactions only. (Which I can get from getblockNumber)

Hope to hear good news from you, thanks for your help!

Could you tell me what information do you need, exactly?
Do you want to view the token transfer information?

Sorry for confusing you, let me explain more:

As we known:

  • Coin != Token.
  • Coin is Klay (main coin of klaytn blockchain)
  • Token is smart contract (KIP7, KIP17…)

Here I am only looking to query transaction history of Klay coin, not tokens. And that information is only available (AFAIK) in getblockNumber(blockNo, true).

Here are an example:

fromBlockNo = 61533531, toBlockNo = 61533631 (baobab network)
I wanna to get all transactions from fromBlockNo to toBlockNo with “type” is “TxTypeLegacyTransaction” only.

Traditional way:

total_transactions = []
(fromBlockNo..toBlockNo).each do |blockNo| # can improve by using thread here but still slow
  data = getblockNumber(61533531, true)
  total_transactions << data['transactions'] # I wanna this data
end

Expected way: Add new api getMultiBlockNumbers(from, to, verbose)

data = getMultiBlockNumbers(fromBlockNo, toBlockNo, true)
total_transactions = data['transactions']

Hi, Is there any new update here

It seems that you can use KAS token history API.

Please check out /v2/transfer.

You can use the below parameters:

  • kind=klay
  • range=0x61533531, 0x61533631 ( you need to input block numbers as hexadecimal, otherwise, it is treated as unix timestamp)

Hope this helps. Thanks.

1개의 좋아요

Thanks @colin.kim . I will take a look at KAS API

1개의 좋아요