简体   繁体   中英

How to download blockchain transaction data?

I wish to download every transaction that happened on blockchain since the genesis. In particular, I want to download data for BSC .

  • How do I download blockchain data?, eg Is there an API or a protocol I can use?
  • Once I've dowloaded the data to date... How do I subscribe to new transactions?

You can run a full node (or connect to an external provider that runs a full node, but most of them have some rate limits and some don't allow subscriptions) and then query the JSON-RPC API.

A widely used wrapper for the JSON-RPC API calls is web3js . You can use their web3.eth library because of the compatilibity between Ethereum and BSC.

If you want to download all transactions, you'll need to loop through all blocks from 1 to latest using the getBlock() method, which also returns all transactions in this particular block.

For subscribing to new transactions, you'll subscribe to the newBlockHeaders event, from which you can get the block number and query the block (see previous paragraph).

You can use BlockchainSpider to collect the data in the blockchain without a full node . In particular, Blockchainspider also supports collecting the data on BSC. Run this command for collecting the metadata, external transactions, and internal transactions of all blocks in BSC:

scrapy crawl blocks.bsc -a types=external,internal

In addition, you can even use BlockchainSpider to collect label data on the blockchain and deeply mine the transaction.network of a specific address .

Enjoy it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM