<p>Would something like the Blockfrost API for watching transactions happening against an address work for you? Something like <a href="https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/%7E1addresses%7E1%7Baddress%7D%7E1transactions/get" rel="nofollow noreferrer">this</a> maybe? You could also query for <a href="https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/%7E1accounts%7E1%7Bstake_address%7D%7E1addresses%7E1assets/get" rel="nofollow noreferrer">assets held by an address</a></p>
<p>Ultimately, you can query specific details using multiple queries and filters on the JSON data returned and probably achieve what you want.</p>

CC BY-SA 4.0
2022-08-08T20:20:45.283Z
Thanks Bharat - I have used Blockfrost, but am seeking to do everything I want to do using only my own node, db-sync, and wallet. 
I do already use db-sync to watch addresses. 
My question is more about how to query what tables to find records related to the use of a specific smart contract - my thought was to build a query that uses the ID of a smart contract as the key to query on, and hopefully to find it's most recent execution, and the tx_outs/assets associated with that, so I could say basically: show me the last time this SC ran and what assets were inputs/outputs in that transaction.
RelevantData
CC BY-SA 4.0
2022-08-08T12:14:16.083Z
2022-08-08T12:14:16.083Z
Bharat Mallapur
<p>Maybe oura is something for you to be worth looking into. <a href="https://github.com/txpipe/oura" rel="nofollow noreferrer">https://github.com/txpipe/oura</a></p>
<p>In a nutshell: Oura allows you to watch for patterns in the blockchain as it progresses and then if you have found a match trigger your own events. So in your case you could have different filters that would trigger the same web enpoint but offer different payloads.</p>

CC BY-SA 4.0
2022-09-13T09:31:34.303Z
2022-09-13T09:31:34.303Z
Manuel Schmidt
<p>Take JPG store as an example.
When someone lists an NFT for sale there, or when someone buys an NFT there, a smart contract governs that transaction.</p>
<p>Can sql queries against the db-sync generated blockchain data &quot;see&quot; that?
I'd like to write sql queries against the db-sync data that show the most recent transaction involving a particular smart contract, but I'm not sure what to query for...</p>
<h2>UPDATE:</h2>
<p>Here is a call to opencnft's free api which allows me to know the most recent transactions involving a particular NFT policy, sorted by date.
If I want to simple replicate that by using sql queries against db-sync, that's also something I am interested in:</p>
<p><a href="https://api.opencnft.io/1/#/Policy/PublicController_getPolicyTx" rel="nofollow noreferrer">https://api.opencnft.io/1/#/Policy/PublicController_getPolicyTx</a></p>
<p>However...that makes the NFT policy the focus of the query, whereas I am also looking for a query that would find the same resulting transaction had occurred but with the Smart Contract being used as the criteria I am querying on.</p>
<p>So in plain language - there are two generalized queries I am hoping to create as a basis and launching pad for other queries?</p>
<ol>
<li><p>select the latest transaction 'Smart Contract X' was involved in, and the  assets involved in that transaction.</p>
</li>
<li><p>select the latest transaction 'Policy Id X' was involved in and any Smart Contracts and/or other assets involved in the transaction.</p>
</li>
</ol>
<p>...sort of like looking for the same thing but from two different perspectives in terms of the criteria and tables involved in building the query?</p>

CC BY-SA 4.0
2022-08-08T01:51:07.890Z
What data specifically are you hoping to get out of `db-sync` ?
Erik de Castro Lopo
CC BY-SA 4.0
2022-08-08T01:57:59.493Z
That a smart contract was executed, and what assets / values were involved..? For example: If someone lists an NFT for sale on JPG store, then the policy of the JPG store smart contract is the signature I am looking for, and I am interested in what asset was listed for sale. The smart contract has an identity, the NFT being listed for sale has an identity, so I am assuming I should be able to build a query that returns the last time a smart contract was executed in a transaction, and what assets are involved in that transaction? Of course, I may have a misconception about what can be queried.
RelevantData
CC BY-SA 4.0
2022-08-08T02:23:19.210Z
Updated with an Edit to give a comparison to opencnft.io
RelevantData
<wallet><cardano-db-sync>
Can db-sync be used to "listen" for transactions involving particular smart contracts?
# Can db-sync be used to "listen" for transactions involving particular smart contracts?

(Asked by: username_0 on 2022-08-07)

Take JPG store as an example.
When someone lists an NFT for sale there, or when someone buys an NFT there, a smart contract governs that transaction.

Can sql queries against the db-sync generated blockchain data "see" that?
I'd like to write sql queries against the db-sync data that show the most recent transaction involving a particular smart contract, but I'm not sure what to query for...

## UPDATE:

Here is a call to opencnft's free api which allows me to know the most recent transactions involving a particular NFT policy, sorted by date.
If I want to simple replicate that by using sql queries against db-sync, that's also something I am interested in:

<https://api.opencnft.io/1/#/Policy/PublicController_getPolicyTx>

However...that makes the NFT policy the focus of the query, whereas I am also looking for a query that would find the same resulting transaction had occurred but with the Smart Contract being used as the criteria I am querying on.

So in plain language - there are two generalized queries I am hoping to create as a basis and launching pad for other queries?

1. select the latest transaction 'Smart Contract X' was involved in, and the assets involved in that transaction.
2. select the latest transaction 'Policy Id X' was involved in and any Smart Contracts and/or other assets involved in the transaction.

...sort of like looking for the same thing but from two different perspectives in terms of the criteria and tables involved in building the query?

**Tags:** wallet, cardano-db-sync
> **Comments:**
> **username_1**: What data specifically are you hoping to get out of `db-sync` ?  
> **username_0**: That a smart contract was executed, and what assets / values were involved..? For example: If someone lists an NFT for sale on JPG store, then the policy of the JPG store smart contract is the signature I am looking for, and I am interested in what asset was listed for sale. The smart contract has an identity, the NFT being listed for sale has an identity, so I am assuming I should be able to build a query that returns the last time a smart contract was executed in a transaction, and what assets are involved in that transaction? Of course, I may have a misconception about what can be queried.  
> **username_0**: Updated with an Edit to give a comparison to opencnft.io  

---

## 2 answers

### Answer by username_2 on 2022-08-08. Score: 1 | Accepted answer

Would something like the Blockfrost API for watching transactions happening against an address work for you? Something like [this](https://docs.blockfrost.io/#tag/Cardano-Addresses/paths/%7E1addresses%7E1%7Baddress%7D%7E1transactions/get) maybe? You could also query for [assets held by an address](https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/%7E1accounts%7E1%7Bstake_address%7D%7E1addresses%7E1assets/get)

Ultimately, you can query specific details using multiple queries and filters on the JSON data returned and probably achieve what you want.

> **Comments:**
> **username_0**: Thanks Bharat - I have used Blockfrost, but am seeking to do everything I want to do using only my own node, db-sync, and wallet.  I do already use db-sync to watch addresses.  My question is more about how to query what tables to find records related to the use of a specific smart contract - my thought was to build a query that uses the ID of a smart contract as the key to query on, and hopefully to find it's most recent execution, and the tx_outs/assets associated with that, so I could say basically: show me the last time this SC ran and what assets were inputs/outputs in that transaction.  

---

### Answer by username_3 on 2022-09-13. Score: 2

Maybe oura is something for you to be worth looking into. <https://github.com/txpipe/oura>

In a nutshell: Oura allows you to watch for patterns in the blockchain as it progresses and then if you have found a match trigger your own events. So in your case you could have different filters that would trigger the same web enpoint but offer different payloads.


---

