How to Query Historical Hedera Data with the DragonGlass REST API
This post was authored by Sreejith Kaimal and Ashu Mahajan, Application Architects at OpenCrowd. OpenCrowd is a design and technology firm that provides custom blockchain development and consulting services to enterprise clients and startups.
Coming to Hedera from a traditional blockchain background, one of the first things users must wrap their heads around is how the network handles state. As a development partner since 2017, we at OpenCrowd are keenly aware that companies building on Hedera need a seamless way to access all of their live and historical data in an operational data store. Additionally, users of these applications may want to access any relevant information about them. These issues are what led us to create the DragonGlass platform.
Accessing Historical Data with DragonGlass
The DragonGlass API is a REST API that allows you to query historical data by transactions and accounts on both the testnet and mainnet.
For instance, if you’d like to query the balance of a given account at a certain point in time you can use the following:
If you’re trying to follow along you’ll need:
I’d also suggest using Postman to make it easy to format. After obtaining a DragonGlass access key, it’s straightforward to retrieve data from DragonGlass. We will start by first submitting a transaction to Hedera.
Create a client
For the JS SDK, the sample client is available on the public repo at github.com/hashgraph/hedera-sdk-js. You could always build a custom client using the protobuf definitions for the Hedera APIs, but we’ll stick to JS SDK for this example.
Once you have set up your Hedera keys, the client can send a transaction. For the sake of our demo we'll do a simple cryptocurrency transfer:
Now we can use the DragonGlass API to monitor this transaction by accountID. Notice you’ll need to add the DragonGlass API key to the GET request.
You can also use DragonGlass to fetch other types of Hedera transactions, such as contract calls, for a contractID in the transaction:
Or fetch a raw transaction for a given DragonGlass generated transactionRecordID:
It is of note that behind the scenes, and before the API even responds to your request, DragonGlass is automating many normally time-consuming services, such as signature verification and unmarshalling / indexing data. We think by doing so, we can help the community focus on building scalable decentralized applications without needing to invest precious time and money in building the platform that houses operational data.
DragonGlass dApp Marketplace
The second major item of interest for dApp creators is the DragonGlass dApp Marketplace. Each dApp is given a dedicated page in the marketplace that provides detailed insight into dApp activities. Users can view transaction history, access smart contract templates and token transfer records, and quickly view stats such as the number of active users.
As the blockchain ecosystem becomes more and more decentralized, the need for a centralized information center becomes increasingly valuable; instead of dApp users having to navigate to multiple locations to reach relevant dApp information, they can simply visit DragonGlass and have all the info they need presented in a single, clean location.
With more and more users convening on DragonGlass each day, creating a dApp page is a simple and easy way to increase your product's visibility for potential new customers, connect with other dApp developers, and create a home base for your users.
The Marketplace is currently live with pages for Tune.fm, Hash Name Service, AdsDax, PlayHash, and AoChain.
To recap, DragonGlass extends Hedera with a wide range of capabilities:
- Customizable Dashboard that works for B2C: Allows your users to enable rich previews of historical transactions on your customer accounts. You can even attach this to your customer profile for a delegated user experience.
- Embedded Transactional Data in your dApp with DragonGlass APIs: Use our rich REST-based APIs to fetch any Hedera data for specific scenarios. Fetch and store data that matter to you most, not the whole thing.
- Configurable Notification Services: Do your customers need alerting? Be it winning a lottery or a large payment, dApp creators can use this service as a way of sending push notifications without the need of constantly asking the network or paying additional fees for fetching records.
- dApp Marketplace: dApp owners can create a page within the DragonGlass dApp Marketplace where users can access detailed dApp data including contracts, byte code, usage, source, and more.
For the time being, we kept our focus on the two aspects of DragonGlass most relevant to dApp developers: the full set of DragonGlass APIs, and the dApp Marketplace. If you would like to feature your dApp on DragonGlass, or to learn more about the platform, please email [email protected] to get your dApp page set up and running.