hyperledger-iroha / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
441 stars 279 forks source link

[suggestion] Add a way of knowing 'incoming transactions' #4204

Open 6r1d opened 10 months ago

6r1d commented 10 months ago

Feature request

To have a way of knowing 'incoming transactions', as it is a topic that was raised during our discussion of Matias's question with @Mingela.

Matias's question:

I think I already got the anser for this but I need to doublecheck. Let's say I got an asset (type quantity).
And I want to get a list of all the transactions that lead to a given account to have the current amount.
So to make it simple, I got two users, User1 mints 100 assets named Token, and transfers 10 of those to User2. 

- If I execute `FindTransactionsByAccountId`for User1, I will get said mint and transfer transactions.
- But if I execute FindTransactionsByAccountId for User2, I get nothing. This is because FindTransactionsByAccountId returns the full set of transactions that the account has submited. 

In other words, there's no way for me to get a list of transactions for User2, because they never submitted any transaction.
So whatever the current amount is for User2, there's no way for me to know who send them assets.
(I mean using Iroha queries, I would need to keep track of those operations my self, somehow)

Bogdan's response:

that's because User2 is just a parameter of a specific instruction of a transaction sent by User1 so he should stick to the first option mentioned (FindTransactionsByAccountId for User1, then filter for transfers which have User2 set as the destination) ...implementing a way of knowing 'incoming transactions' may be useful on the query level. For now it's possible via an offchain middleware/indexer...

Motivation

Knowing the incoming transactions may be useful on the query level.

Who can help?

No response

Mingela commented 10 months ago

And this is definitely a use case for the blockchain explorer and any finance app (to know who sent me assets). WSV should already have enough, it seems this could be solved with just expanding query API

mversic commented 10 months ago

Since smart contracts are opaque, to support a feature like this we should at every smart contract execution mark which entities (like assets in the case of this ticket) it modified.