<p>There are different ways.</p>
<p>You can do what jnprogrammer said, or you can run the graphql setup <a href="https://github.com/input-output-hk/cardano-graphql" rel="noreferrer">https://github.com/input-output-hk/cardano-graphql</a> providing an entire stack of tools including the API (graphQL).</p>
<p>The graphQL query you're looking for could look like this</p>
<pre><code>query {
  transactions(where: {outputs: {address: {_eq:&quot;addr1...&quot;}}}) {
    outputs {
      address
      value
    }
  }
}
</code></pre>
<p>and you'll receive a list of sending address and receiving address with the amounts in lovelace</p>
<p>If you don't want to build and run any of that yourself, you could also use a public API. I am not sure if there are any reliable public graphQL endpoints out there, but e.g. <a href="https://blockfrost.io" rel="noreferrer">blockfrost.io</a> offers a REST API.
The downside of that is you rely on a third party and you depend on that service being up to date with the network and always up and running. On the other hand, depending on your experience and admin skills, it can also be the more reliable option :)</p>

CC BY-SA 4.0
2021-10-17T15:23:59.440Z
Thanks for the reply! That's exactly what I was looking for from an API standpoint, and your clarification is much appreciated, I may go with the REST API after some investigating. Now if I can just find a way to get that query to trigger every few minutes or so in my web app, it would be as close as possible to constantly "listening" to all sending addresses.
KronosXekri
CC BY-SA 4.0
2021-10-19T07:13:40.493Z
Just to follow on this good answer, you might use the websocket-link with Blockfrost https://github.com/blockfrost/blockfrost-websocket-link
Marek Mahut - StakeNuts
CC BY-SA 4.0
2021-10-17T07:06:54.053Z
2021-10-17T07:06:54.053Z
LACE pool
<p>What info do you wanna get specifically? If it is just the UTXO's at an address and you are running a node then the following script suffices.</p>
<blockquote>
<p>#!/bin/bash</p>
<p>cardano-cli query utxo --mainnet --address $(cat ~/path/to/file.addr) &gt; ~/UtxosAtAddress</p>
</blockquote>
<p>If you would like more info on transactional data you could run the cardano-db-sync package in along side the node. Via this you can query a lot of data, but it does require some PostgreSQL knowledge.</p>
<p>Now if you have no interest in running a node or the cardano-db-sync, you could also query third party api's. A nice one to mention is Blockfrost that has multiple languages supported. For more info on this see their website [<a href="https://blockfrost.io/" rel="nofollow noreferrer">1</a>]</p>

CC BY-SA 4.0
2021-10-26T10:37:08.890Z
2021-10-26T10:37:08.890Z
Fermat
<p>How about running a Cardano node and build a script that queries the target address and produces something consumable by your API?</p>

CC BY-SA 4.0
2021-10-17T15:17:40.567Z
Thanks for the reply! This sounds something I would be interested in doing, but where do I start with this "script"? Excuse me for my inexperience, but this script is somehow connected to the cardano-node I'm running? Something "consumable" by my API means an output the code in my web app could interpret?
KronosXekri
CC BY-SA 4.0
2021-10-17T00:18:38.347Z
2021-10-17T00:18:38.347Z
jnprogrammer
<p>I believe this guide would help you out:
<a href="https://developers.cardano.org/docs/integrate-cardano/listening-for-payments-wallet/" rel="nofollow noreferrer">https://developers.cardano.org/docs/integrate-cardano/listening-for-payments-wallet/</a></p>

CC BY-SA 4.0
2021-12-31T21:00:12.697Z
this is polling, not listening
Eugene
CC BY-SA 4.0
2021-11-08T17:32:39.967Z
2021-11-08T17:32:39.967Z
Medardas
<p>All the above solutions can do the job, but you'll end up polling the blockchain on each one. Another solution though is using <a href="https://www.tangocrypto.com" rel="nofollow noreferrer">tangocrypto</a> services. Their <a href="https://docs.tangocrypto.com/notify/notify/using-webhooks" rel="nofollow noreferrer">webhooks</a> feature will allow you to &quot;react&quot; to different blockchain events such as PAYMENT. So you just need to set up a webhook and start <strong>listening</strong> to a specific address. You will get a callback notifying you every time the address receive a payment.</p>

CC BY-SA 4.0
2021-10-26T01:53:14.857Z
2021-10-26T01:53:14.857Z
leobelizquierdo
<p>For a web app, I'm wondering is there an API/SDK that enables you to execute some code every time an address receives ADA, NFT, or native token? The wallet address receiving does not change. If not, what repos should I start at for building this sort of functionality?</p>
<p>For example, I'm selling NFTs on my website and my wallet address is shown which anyone can send a specific amount of ADA to in order to get a random NFT from the collection. I want to execute the functions which pick a random NFT from the collection to mint every time my wallet receives the specified amount of ADA.</p>

CC BY-SA 4.0
2022-05-05T08:05:23.093Z
You have a lot of answers, good time to mark one as accepted :-)
gRebel
<cardano-cli><nft><api><javascript>
How can you listen to all incoming transactions of a wallet address?
# How can you listen to all incoming transactions of a wallet address?

(Asked by: username_0 on 2021-10-16)

For a web app, I'm wondering is there an API/SDK that enables you to execute some code every time an address receives ADA, NFT, or native token? The wallet address receiving does not change. If not, what repos should I start at for building this sort of functionality?

For example, I'm selling NFTs on my website and my wallet address is shown which anyone can send a specific amount of ADA to in order to get a random NFT from the collection. I want to execute the functions which pick a random NFT from the collection to mint every time my wallet receives the specified amount of ADA.

**Tags:** cardano-cli, nft, api, javascript
> **Comments:**
> **username_1**: You have a lot of answers, good time to mark one as accepted :-)  

---

## 5 answers

### Answer by username_2 on 2021-10-17. Score: 8

There are different ways.
You can do what jnprogrammer said, or you can run the graphql setup https://github.com/input-output-hk/cardano-graphql providing an entire stack of tools including the API (graphQL).
The graphQL query you're looking for could look like this
query {
  transactions(where: {outputs: {address: {_eq:"addr1..."}}}) {
    outputs {
      address
      value
    }
  }
}

and you'll receive a list of sending address and receiving address with the amounts in lovelace
If you don't want to build and run any of that yourself, you could also use a public API. I am not sure if there are any reliable public graphQL endpoints out there, but e.g. blockfrost.io offers a REST API.
The downside of that is you rely on a third party and you depend on that service being up to date with the network and always up and running. On the other hand, depending on your experience and admin skills, it can also be the more reliable option :)

> **Comments:**
> **username_0**: Thanks for the reply! That's exactly what I was looking for from an API standpoint, and your clarification is much appreciated, I may go with the REST API after some investigating. Now if I can just find a way to get that query to trigger every few minutes or so in my web app, it would be as close as possible to constantly "listening" to all sending addresses.  
> **username_3**: Just to follow on this good answer, you might use the websocket-link with Blockfrost https://github.com/blockfrost/blockfrost-websocket-link  

---

### Answer by username_6 on 2021-11-08. Score: 4

I believe this guide would help you out:
<https://developers.cardano.org/docs/integrate-cardano/listening-for-payments-wallet/>

> **Comments:**
> **username_7**: this is polling, not listening  

---

### Answer by username_4 on 2021-10-26. Score: 3

What info do you wanna get specifically? If it is just the UTXO's at an address and you are running a node then the following script suffices.

> #!/bin/bash
>
> cardano-cli query utxo --mainnet --address $(cat ~/path/to/file.addr) > ~/UtxosAtAddress

If you would like more info on transactional data you could run the cardano-db-sync package in along side the node. Via this you can query a lot of data, but it does require some PostgreSQL knowledge.

Now if you have no interest in running a node or the cardano-db-sync, you could also query third party api's. A nice one to mention is Blockfrost that has multiple languages supported. For more info on this see their website [[1](https://blockfrost.io/)]


---

### Answer by username_5 on 2021-10-17. Score: 3

How about running a Cardano node and build a script that queries the target address and produces something consumable by your API?

> **Comments:**
> **username_0**: Thanks for the reply! This sounds something I would be interested in doing, but where do I start with this "script"? Excuse me for my inexperience, but this script is somehow connected to the cardano-node I'm running? Something "consumable" by my API means an output the code in my web app could interpret?  

---

### Answer by username_8 on 2021-10-26. Score: 3

All the above solutions can do the job, but you'll end up polling the blockchain on each one. Another solution though is using [tangocrypto](https://www.tangocrypto.com) services. Their [webhooks](https://docs.tangocrypto.com/notify/notify/using-webhooks) feature will allow you to "react" to different blockchain events such as PAYMENT. So you just need to set up a webhook and start **listening** to a specific address. You will get a callback notifying you every time the address receive a payment.


---

