<p>The current state of Plutus makes this impossible to do. Instead, you have to try and use a custom DB-sync server, and then construct the off-chain code in such a way that it passes the looked-up values to the Haskell program.</p>
<p>Note that you will have to use lifting to ensure that the values passed by the Haskell code, can configure the Plutus app.</p>
<p>The state of Plutus mentioned here is everything available on and before  Feb 22 2022.</p>

CC BY-SA 4.0
2022-02-22T17:07:48.277Z
2022-02-26T09:20:31.070Z
2022-02-26T09:20:31.070Z
KryptoKing
<p>I am trying to implement so logic to ensure smart contract (SC) validation upon certain conditions - which are derived from the end-users transaction history.</p>
<p>If I parameterise the SC and take the users address or public key hash (pkh) how can I look up the last N transactions to/sent from that address.</p>
<p>I need to be able to do this within the mkValidator logic.</p>
<p>Example:</p>
<p><code>mkValidator :: pkh -&gt; () -&gt; () -&gt; () -&gt; Bool</code></p>
<p><code>mkValidator pkh _ _ _ </code></p>
<p><code>| pkh last transaction was to the specified user = True</code></p>
<p><code>| otherwise = False</code></p>
<p>I am attempting to make some free and opensource code for the community that tackle a fundamental problem in the Cardano protocol (i.e. it scales with the number of users) so I am attempting to stay away from blockfrost and other paid API services.</p>

<plutus-pioneer-program><api><blockfrost><validation><transaction-metadata>
How to retrieve an addresses transaction history inside a plutus contract
# How to retrieve an addresses transaction history inside a plutus contract

(Asked by: username_0 on 2022-02-21)

I am trying to implement so logic to ensure smart contract (SC) validation upon certain conditions - which are derived from the end-users transaction history.

If I parameterise the SC and take the users address or public key hash (pkh) how can I look up the last N transactions to/sent from that address.

I need to be able to do this within the mkValidator logic.

Example:

`mkValidator :: pkh -> () -> () -> () -> Bool`

`mkValidator pkh _ _ _`

`| pkh last transaction was to the specified user = True`

`| otherwise = False`

I am attempting to make some free and opensource code for the community that tackle a fundamental problem in the Cardano protocol (i.e. it scales with the number of users) so I am attempting to stay away from blockfrost and other paid API services.

**Tags:** plutus-pioneer-program, api, blockfrost, validation, transaction-metadata

---

## 1 answers

### Answer by username_0 on 2022-02-22. Score: 1 | Accepted answer

The current state of Plutus makes this impossible to do. Instead, you have to try and use a custom DB-sync server, and then construct the off-chain code in such a way that it passes the looked-up values to the Haskell program.

Note that you will have to use lifting to ensure that the values passed by the Haskell code, can configure the Plutus app.

The state of Plutus mentioned here is everything available on and before Feb 22 2022.


---

