December 18, 2023

How to Watch On-Chain Transactions – Monitor Crypto Transactions and Events

Table of Contents
Check out Moralis´ Streams API for the best way to work with real-time blockchain data!
How to Watch On-Chain Transactions – Monitor Crypto Transactions and Events

In today’s article, we’ll dive into the intricacies of on-chain analytics. And in doing so, we’ll show you how to watch on-chain 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 on-chain 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 on-chain 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 on-chain analytics. In doing so, we’ll cover what it entails, how it works, and explain why you should watch on-chain transactions. From there, we’re going to explore the intricacies of on-chain 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 on-chain transactions and build on-chain 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 on-chain analytics! 

What is On-Chain 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 ”on-chain” 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 on-chain analytics. 

But what precisely does on-chain analytics entail? 

Put simply, on-chain analytics is the process of analyzing, interpreting, and understanding on-chain 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 on-chain analytics – which we’ll mainly focus on in this article – is to watch blockchain transactions. Watching on-chain 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, on-chain 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 – on-chain analytics gives you a unique and significant advantage in understanding everything that happens on a network.  

Nevertheless, that gives you an overview of what on-chain analytics entails. Let’s now take a closer look at how it works in the following section! 

How Does On-Chain Analytics Work? 

There isn’t a fixed method for on-chain 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 on-chain analytics works: 

  • Watch Transactions: A common approach to on-chain 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: On-chain 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 on-chain transactions, wallet balances are also recorded on blockchain networks. Consequently, with on-chain 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 on-chain analytics works, let’s further explore why you should watch on-chain transactions! 

Why Should You Watch On-Chain Transactions? 

From a broad perspective, it’s easy to understand why on-chain 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 on-chain 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 on-chain analytics tools, such as real-time wallet trackers, crypto whale watchers, and much more.

All in all, watching transactions and other critical on-chain events gives you and your potential users valuable insight into what’s happening on the various blockchain networks!

What are On-Chain Analytics Platforms? 

On-chain 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 on-chain analytics platforms enter the equation! 

On-chain 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 on-chain 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: On-chain analytics platforms also typically feature notification systems. This allows you to watch and analyze on-chain 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 on-chain transactions and build your own analytics tools! 

Introducing Moralis’ Streams API – The Easiest Way to Watch On-Chain Transactions 

The easiest way to watch on-chain 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 on-chain 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 on-chain 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 on-chain transactions in three steps! 

3-Step Tutorial: How to Watch On-Chain Transactions with the Streams API 

Setting up a stream with Moralis’ Streams API to watch on-chain 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 on-chain 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 On-Chain Wallet Trackers: As the Streams API allows you to watch on-chain transactions, you can effortlessly use this industry-leading tool to build an on-chain 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 on-chain 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 On-Chain Transactions

In today’s article, we kicked things off by exploring the ins and outs of on-chain analytics. In doing so, we learned that it is the process of analyzing on-chain data – including transactions, wallet addresses, etc. – to understand market sentiment, trends, and user behavior. 

From there, we also dove into on-chain analytics platforms, which are tools that fetch, analyze, and interpret raw blockchain data, making it easier for users to understand what’s going on on-chain. 

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 on-chain transactions in three simple steps: 

  1. Configure a stream
  2. Start the stream
  3. Add addresses you wish to monitor to the stream

Consequently, if you have followed along, you can now seamlessly watch on-chain transactions and other events with the Streams API! 

If you liked this on-chain 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 on-chain 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! 

Streams API
Stream Web3 events and get real-time notifications whenever something important happens on-chain!
Streams API
Related Articles
September 27, 2023

What is an Ethereum Node and How to Set One Up

October 14, 2023

The Ultimate Guide to NFT Marketplace Development

January 22, 2024

Exploring the Polygon Ecosystem – Full Guide to Dapps on Polygon

November 30, 2023

The Biggest and Most Popular Blockchains for Developers

December 14, 2022

Ethers.js Tutorial – How to Get Started Using a Simple Ethers.js Example

November 23, 2022

Blockchain Infrastructure – The Tech and Landscape Empowering Developers

September 17, 2022

How to Set Up a Self-Hosted Web3 Server

November 29, 2022

The Best ERC20 Token Balance API for Dapp Development

September 6, 2022

How to Build a Polygon Dapp in 3 Steps