---
title: Litecoin transaction monitoring is a breeze 💨 with Web3data.js!
description: Learn how to Combine the power of real time websocket events and RPC methods to watch for when transactions within the Litecoin mempool get confirmed!
---

[Amberdata Blog ](https://blog.amberdata.io)

# [Litecoin transaction monitoring is a breeze 💨 with Web3data.js!](https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js)

 Written by [Taylor Dawson](https://blog.amberdata.io/author/taylor-dawson) | Nov 25, 2019

## <https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js?hs_amp=true#learn-how-to-combine-the-power-of-real-time-websocket-events-and-rpc-methods-to-watch-for-when-transactions-within-the-litecoin-mempool-get-confirmed-also-applies-to-all-other-supported-blockchains-yay->Learn how to Combine the power of real time websocket events and RPC methods to watch for when transactions within the Litecoin mempool get confirmed! (Also applies to all other supported blockchains. Yay! 🙌)

## <https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js?hs_amp=true#tldr>TLDR;

If you’d like to use the runkit or run the code yourself, be sure to [get your free API Key](https://amberdata.io/onboarding) on our website. It shouldn’t take more than few minutes. Don’t worry! This article will still be here when you’re finished.

Got it? Great, let’s begin!

```
const w3d = new Web3Data("YOUR API KEY", {    blockchainId: 'f94be61fd9f4fa684f992ddfd4e92272'})
```

First we create the `Web3Data` instance and pass in all of the necessary configuration options. You’ll see here that we are specifying the Litecoin blockchain Id. In [our documentation](https://docs.amberdata.io/reference#blockchain-ids) you’ll find a complete list of supported blockchains and their corresponding blockchain Ids.

```
w3d.connect()
```

Next, we establish a connection with the websocket server.

```
const {result: txnHashes} = await w3d.ltc.rpc('getrawmempool')
```

We make the `getrawmempool` RPC request to the Litecoin node which returns an array of the transaction hashes of the transactions within the mempool. We’ll object destructure the result property, which contains the array, into the `txnHashes` variable.

As you can see making RPC requests with [Web3data.js](https://web3data.github.io/web3data-js/#/) is super simple! To see the full list of available RPC requests you can check out [our documentation](https://docs.amberdata.io/reference#getbestblockhash).

```
txnHashes.forEach( txnHash => {    console.log('Subscribing to transaction: ' + txnHash.slice(0,8))    subscribe(txnHash)})
```

Iterate over each transaction hash and log that we are now subscribing to this transaction; thus watching for it’s exit from the mempool. We only log the first 8 characters for readability.

```
const subscribe = hash => {    w3d.on({eventName: 'transaction', filters: {hash}}, (txn) => {        console.log(`Transaction: ${hash.slice(0,8)} exited mempool.`)    })}
```

Finally, we have our subscribe method which sends a websocket subscription request to the websocket server. We specify the name of the event we want to subscribe to using the `eventName` property. Using the `filters` option we pass in the hash of a pending transaction that we want to watch for. In this case, it’s the has of the pending transaction we got from the Litecoin mempool. Then we log that the transaction left the mempool and got confirmed.

You can see more details in our documentation about websockets and the [transaction event](https://docs.amberdata.io/reference#ws-transactions) and be sure to see [more examples](https://web3data.github.io/web3data-js/#/examples?id=websockets) using Web3data.js websockets.

# <https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js?hs_amp=true#conclusion>Conclusion

Web3data.js is a powerful library that makes consuming blockchain data a breeze. This is just one of the many ways that you can utilize Web3data.js. Be sure to check out the [examples](https://web3data.github.io/web3data-js/#/examples?id=fetching-data) in the documentation and stay tuned for other tutorials!

Also if you have any questions at all please feel free to reachout!

# <https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js?hs_amp=true#previous-tutorials>Previous Tutorials:

- [Web3data.js — The new web3.js & ether.js drop-in replacement→](https://medium.com/amberdata/web3data-js-the-new-web3-js-ether-js-drop-in-replacement-73202378c58c)
- [Web3data-js — Getting real-time Ethereum blockchain and market data has never been easier](https://medium.com/amberdata/web3data-js-getting-real-time-ethereum-blockchain-and-market-data-has-never-been-easier-af72b02eda2f)
- [The definitive guide to successfully integrating off-chain data into your Ethereum smart contract with Chainlink & Amberdata](https://medium.com/amberdata/the-definitive-guide-to-successfully-integrating-off-chain-data-into-your-ethereum-smart-contract-ec81d95ea441)
- [How do I get a list of my Ethereum ERC20 tokens?](https://medium.com/amberdata/how-do-i-get-a-list-of-my-ethereum-erc20-tokens-tutorial-part-2-df1aafef3eed)
- [How do I #Buidl an Ethereum lite wallet?](https://medium.com/amberdata/how-do-i-buidl-an-ethereum-lite-wallet-tutorial-11c990ac0ba6)
- [Stop spending high Gas & Fees on Ethereum](https://medium.com/amberdata/stop-spending-high-gas-fees-on-ethereum-tutorial-491740c2ad66)

# <https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js?hs_amp=true#for-more-information-about-amberdataio>For more information about Amberdata.io:

- Website: [Amberdata.io](https://amberdata.io/)
- Twitter: [Amberdataio](https://twitter.com/amberdataio)

[View full post](https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Taylor Dawson"
  },
  "dateModified" : "2021-11-17T16:46:35.434Z",
  "datePublished" : "2019-11-25T16:00:00Z",
  "headline" : "Litecoin transaction monitoring is a breeze 💨 with Web3data.js!",
  "image" : {
    "@type" : "ImageObject",
    "height" : 1468,
    "url" : "https://f.hubspotusercontent40.net/hubfs/20854245/Imported_Blog_Media/litecoin_txn_websockets_e0fa035_cd530712607602b57794d0e9ea5f8bfe-1.png",
    "width" : 1262
  },
  "mainEntityOfPage" : "https://blog.amberdata.io/litecoin-transaction-monitoring-is-a-breeze-with-web3data-js",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60.0,
      "url" : "https://f.hubspotusercontent40.net/hubfs/20854245/Amberdata%20logo%20500.png",
      "width" : 468.75
    },
    "name" : "Amberdata Blog"
  }
}
```