How to pull data from the Cardano blockchain?

Hey Team

Perhaps this is a bit of a silly question, but I figured why not ask!
I’m trying to wrap my head around how exactly wallet/exchange applications are pulling data from the blockchain.

The main thing I’m confused about is that since the data is being hosted in a distributed manner across the world, what would be the means of fetching data such as the current epoch/slot, or personal wallet details?

I come from the mobile app world where (roughly) our network requests point at a single ‘base url’, with various endpoints according to the tail end of the url which we hand off to our libraries to perform the actual requests.

Am I wrong to think that there must be some sort of central point of access in order to fetch this data? I’ve stumbled across https://hydra.iohk.io/build/5367762/download/1/mainnet-topology.json which… seems like something I was looking for…? but TBH, I have absolutely no idea if that’s relevant or not.

In my head it’d be great to just open up a connection to some IOHK hosted gRPC stream, and pull down data about the blockchain. But I feel like it’s likely not that simple.

My second guess would be that the client needs to act as a node in the network, and get the data that way. However I don’t know if there are any obligations to participate in block verification and all of that.

Any pointers/TLDRs would be very much appreciated! I’d love to get into this space and start writing some code. Thanks in advance :heart:

While the mentioned parameters (epoch/slot) dont need a node to query, they’re essentially just a way to express time in blockchain units, for other parameters that you do query from node (eg: tip, protocol parameters, balance of address, etc. you could simply host a node yourself or connect to a public service, using the corresponding endpoint. Each node is a self sustaining copy of chain and as long as its in sync, your node - or a modular component built to query against node - can be used as an endpoint for your Integration.

2 Likes

Awesome, thanks for the info! I guess my next step should be understanding how exactly that works.

Would a wallet app derive the balance of the user’s wallet by going through all of the transactions in the complete chain, meaning it’s completely necessary to get and maintain a complete copy of the chain locally? I’m wondering how feasible it is to bring this to a phone without using a central service (which I think is what Yoroi does?), given how much of a commitment it is to sync and store the whole thing.

EDIT:
From reading through the lift-wallet source, it appears that transaction history is derived like that, by iterating across every transaction and filtering by those which are associated with particular addresses.

And it looks like for wallet balance, there’s something called Dandelion which appears to be a free API for getting transaction data for particular addresses. I’m wondering why balance isn’t derived in the same manner as transaction history - perhaps it could be and it’s done this way as a means of getting the balance potentially a lot faster.

This is all good stuff to go from. :partying_face: