
In today’s article, we’ll dive into the intricacies of onchain analytics. And in doing so, we’ll show you how to watch onchain transactions and other events using Moralis’ Streams API. With this industry-leading development tool, you can effortlessly set up your own streams to get real-time notifications sent directly to the backend of your Web3 projects via webhooks!
If you want to jump straight into the action, here’s a quick 3-step breakdown on how to use the Streams API to watch onchain transactions:
- Step 1 – Choose the blockchains you’re interested in, specify what transactions/events you want to listen to, and add a webhook destination:
- Step 2 – Set up a stream using your ”stream” object and receive a test webhook in return:
- Step 3 – Add one or millions of addresses you want to monitor to your stream:
That’s it; when working with Moralis’ Streams API, it’s easy to watch onchain transactions!
However, to learn more about this, join us in this article as we cover Moralis’ Streams API in further detail and provide a more in-depth breakdown of the steps above!
Overview
We’ll kickstart today’s tutorial by diving into the ins and outs of onchain analytics. In doing so, we’ll cover what it entails, how it works, and explain why you should watch onchain transactions. From there, we’re going to explore the intricacies of onchain analytics tools and why they are needed. Lastly, to top things off, we’ll introduce you to Moralis’ Streams API, as this is the easiest way to watch onchain transactions and build onchain analytics platforms!
Furthermore, if you have ambitions to build Web3 projects and decentralized applications (dapps), then we recommend checking our Moralis further. Moralis is an industry-leading Web3 API provider, and in our suite of premier interfaces, you’ll find tools such as the NFT API, Wallet API, and many others. With tools like these, you can effortlessly build everything from NFT dapps to block explorers. To learn more, check out all our APIs by visiting the Web3 API page!
Also, did you know you can access all Moralis APIs for free? As such, sign up with Moralis immediately, and you’ll be able to start leveraging the full potential of blockchain technology today!
Nonetheless, let’s dive into the first section and explore the ins and outs of onchain analytics!
What is Onchain Analytics?
The vast majority of all cryptocurrencies, smart contracts, and decentralized applications (dapps) leverage public blockchains – like Ethereum, Bitcoin, BNB Smart Chain (BSC), Polygon, etc. – to verify and record data. And this information is universally available ”onchain” to anyone, anywhere in the world.
Given the public accessibility of the data stored on the biggest blockchains, it becomes possible to use this information in various ways to determine market sentiment, identify trends, and understand user behavior, a process that we generally refer to as onchain analytics.
But what precisely does onchain analytics entail?
Put simply, onchain analytics is the process of analyzing, interpreting, and understanding onchain data – including transactions, wallet balances, smart contract events, block data, and more – to gain valuable insight into various blockchain networks!
One of the most common approaches to onchain analytics – which we’ll mainly focus on in this article – is to watch blockchain transactions. Watching onchain transactions reveals loads of essential information. For instance, it can tell us how crypto whales are trading, help identify newly minted tokens, analyze exchange flows, and much more.
Moreover, onchain analytics is quite a unique approach, as other asset classes, traditional applications, etc., don’t run on public blockchain ledgers. As such, if you’re involved in the Web3 space in any capacity – whether you’re trading or building dapps – onchain analytics gives you a unique and significant advantage in understanding everything that happens on a network.
Nevertheless, that gives you an overview of what onchain analytics entails. Let’s now take a closer look at how it works in the following section!
How Does Onchain Analytics Work?
There isn’t a fixed method for onchain analytics, but rather several approaches to understanding what’s happening on a blockchain network. In this section, we’ll briefly look at three commonly used methods to give you some examples of how onchain analytics works:
- Watch Transactions: A common approach to onchain analytics is to watch the flow of transactions. Each transaction recorded on a blockchain network contains a unique hash, to and from addresses, timestamps, the amount sent, etc. And with this information, it’s possible to see where and when the money moves. One common use case for this might be to track a successful investor to copy their trading strategy.
- Analyzing Exchange Flows: Onchain analytics also entails analyzing how funds move between non-custodial wallets and big exchanges like Binance, Coinbase, etc. With this information, it becomes possible to identify overarching market trends. For instance, a significant inflow of crypto to exchanges is typically a negative sign, as it can indicate intent to sell.
- Examine Wallet Holdings: Like onchain transactions, wallet balances are also recorded on blockchain networks. Consequently, with onchain analytics, it’s possible to examine holdings to see what other users or organizations have in their wallets.
Now that we have covered a few examples of how onchain analytics works, let’s further explore why you should watch onchain transactions!
Why Should You Watch Onchain Transactions?
From a broad perspective, it’s easy to understand why onchain analytics matters. Billions and billions of dollars are traded on the various blockchain networks each and every day, and understanding these transactions gives better insight into market sentiment, user behavior, and current trends.
As such, if you watch onchain transactions, you can get an edge in the market so you can maximize your personal return on investment when it comes to trading crypto. However, you can also use this information to build your own onchain analytics tools, such as real-time wallet trackers, crypto whale watchers, and much more.
All in all, watching transactions and other critical onchain events gives you and your potential users valuable insight into what’s happening on the various blockchain networks!
What are Onchain Analytics Platforms?
Onchain analytics is a beneficial approach to understanding the market; however, acquiring, analyzing, and making sense of raw blockchain data, such as transactions, can be quite challenging. Fortunately, this is where onchain analytics platforms enter the equation!
Onchain analytics platforms are basically tools for understanding and gaining insight into the various blockchain networks. These tools fetch, analyze, and interpret data straight from the blockchain networks, so you don’t have to. Consequently, they make blockchain analytics significantly more accessible.
However, to better highlight the benefits of these platforms, let’s look at three prominent features:
- Labeling: Prominent onchain analytics platforms provide labels, making it easier to identify protocols, tokens, addresses, etc., involved in transactions.
- Filtering: Some platforms also allow you to filter irrelevant transactions so you can zero in on particular protocols, networks, transaction types, and so on.
- Notifications: Onchain analytics platforms also typically feature notification systems. This allows you to watch and analyze onchain transactions even when you aren’t actively in front of your screen.
Now, with an overview of what on-chan analytics tools are, you might be interested in building one yourself. If this is the case, join us in the next section as we introduce you to Moralis’ Streams API – the ultimate tool to watch onchain transactions and build your own analytics tools!
Introducing Moralis’ Streams API – The Easiest Way to Watch Onchain Transactions
The easiest way to watch onchain transactions and build blockchain analytics tools is to leverage Moralis’ Streams API. With the Streams API, you can effortlessly set up your own customized streams to automatically get real-time updates regarding essential Web3 events and transactions. And thanks to the accessibility of this industry-leading tool, you can get these updates sent directly to the backend of your projects via Web3 webhooks!
The Streams API covers 44 million contracts and supports all types of transactions, events, NFTs, smart contracts, wallets, and more. Moreover, the Streams API is entirely cross-chain compatible, meaning you can set up streams on multiple networks. This includes blockchains like Ethereum, BSC, Polygon, Avalanche, and many others.
So, why should you leverage the Streams API to watch onchain transactions?
Well, to answer the question above, let’s look at three prominent benefits of this industry-leading tool:
- Total Customization: Moralis’ Streams API is the industry’s most dynamic and flexible real-time API for onchain data. With it, you can set up Streams for any custom Web3 use case you can imagine.
- Built for Scale: The Streams API offers unparalleled scalability. For instance, you can listen to 100 million of the most active Ethereum wallets with only a single stream.
- Go To Market Faster: The Streams API monitors, ingests, indexes, and tailors real-time data for you. This means you can leverage this premier tool to take your projects to market faster and at a lower cost.
So, how does the Streams API work?
For the answer to the query above, join us in the next section as we show you how to watch onchain transactions in three steps!
3-Step Tutorial: How to Watch Onchain Transactions with the Streams API
Setting up a stream with Moralis’ Streams API to watch onchain transactions is super simple. All it takes are three simple steps:
- Step 1 – Start by importing Moralis and adding your API key. From there, configure your Moralis stream by selecting the chains you’re interested in, picking what transactions you want to watch, and adding a webhook destination to the “options” object:
const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");
Moralis.start({
apiKey: “YOUR_API_KEY”,
});
async function streams(){
const options = {
chains: [EvmChain.SEPOLIA],
tag: "transfers",
description: "Listen to Transfers",
includeContractLogs: false,
includeNativeTxs: true,
webhookUrl: "replace_me"
}
//…
}
- Step 2 – Add the code for creating your stream and fetching the “id”:
//…
const newStream = await Moralis.Streams.add(options)
const {id} = newStream.toJSON();
//…
- Step 3 – Add one or more addresses to your stream:
//…
const address = "0xa50981073aB67555c14F4640CEeB5D3efC5c7af2";
await Moralis.Streams.addAddress({address, id})
//..
Here’s an example of what the final code should look like:
const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");
Moralis.start({
apiKey: “YOUR_API_KEY”,
});
async function streams(){
const options = {
chains: [EvmChain.SEPOLIA],
tag: "transfers",
description: "Listen to Transfers",
includeContractLogs: false,
includeNativeTxs: true,
webhookUrl: "replace_me"
}
const newStream = await Moralis.Streams.add(options)
const {id} = newStream.toJSON();
const address = "0xa50981073aB67555c14F4640CEeB5D3efC5c7af2";
await Moralis.Streams.addAddress({address, id})
console.log("Stream successfully created")
}
streams()
That’s it! It doesn’t have to be more challenging than that to watch onchain transactions and other events when working with the Streams API!
Nevertheless, for a more in-depth breakdown of this process, check out the official Streams API documentation page or tune into the Moralis YouTube video below:
Streams API Use Cases
Since the Streams API is super dynamic, you can use this tool to create streams for almost any use case. Consequently, it doesn’t matter if you’re building software wallets, NFT marketplaces, or any other Web3 platform; the Streams API will likely come in handy!
However, to give you some inspiration, here are three examples of prominent Streams API use cases:
- Build Onchain Wallet Trackers: As the Streams API allows you to watch onchain transactions, you can effortlessly use this industry-leading tool to build an onchain wallet tracker. In doing so, you can watch addresses of interest to, for instance, copy their trading strategy.
- Watch Whales: Use the Streams API to watch the onchain transactions of cryptocurrency whales automatically and in real-time. This can be essential, as whales have the potential to influence the market with their trades.
- Set Up Real-Time Notifications: With the Streams API, you can set up notification systems for any of your Web3 projects. In doing so, you can maximize engagement and keep your users updated in real-time so they never miss a beat.
However, the use cases above are only three prominent examples, and your options with the Streams API are endless. Consequently, the only thing limiting you is your imagination!
Summary: How to Watch Onchain Transactions
In today’s article, we kicked things off by exploring the ins and outs of onchain analytics. In doing so, we learned that it is the process of analyzing onchain data – including transactions, wallet addresses, etc. – to understand market sentiment, trends, and user behavior.
From there, we also dove into onchain analytics platforms, which are tools that fetch, analyze, and interpret raw blockchain data, making it easier for users to understand what’s going on onchain.
Next, we introduced you to Moralis’ Streams API, which is the easiest way to monitor blockchain activity in real-time. In doing so, we showed you how to watch onchain transactions in three simple steps:
- Configure a stream
- Start the stream
- Add addresses you wish to monitor to the stream
Consequently, if you have followed along, you can now seamlessly watch onchain transactions and other events with the Streams API!
If you liked this onchain analytics tutorial, consider checking out more content on Moralis’ Web3 blog. For instance, explore the best crypto faucet sites or dive into the intricacies of Web3 as a service!
Also, if you want to build onchain analytics platforms or other Web3 projects, remember to sign up with Moralis. You can create an account for free, and you’ll get immediate access to all our industry-leading Web3 APIs!