<p>i was actually able to do this:</p>
<pre><code>    txinfo :: Contexts.TxInfo
    txinfo = Contexts.scriptContextTxInfo context

    txInputs = Contexts.txInfoInputs txinfo

    validatedValue = Contexts.txOutValue . Contexts.txInInfoResolved &lt;$&gt; txInputs
</code></pre>
<p>With this i was able to get all the UTXOs submitted to the transaction.
It still means the submit transaction need to gather UTXO's and submit it with tx-in to the transaction.
Obviously there might be some limits on how many tx-in you can submit based on the transaction size etc.
But i was able to submit 2 UTXO as tx-in and with Contexts.txInfoInputs was able to get both amounts locked at the script at once.</p>
<p>Contexts.findOwnInput seems to validate 1 at a time even when 2 tx-in are submitted. So i would NOT know the combined value of both UTXOs at this script address.
I would be interested to know whats other solutions are there that could be even better</p>

CC BY-SA 4.0
2023-01-06T23:46:49.017Z
i realized later i think Cause script cannot see whole blockchain but only utXos submitted with the Txn. So i still am working but i think we can use NFT at script to instead use redeem actions to add contributions and that way update datum with target amount. and then i know if total target reached or not.
Chakravarti Raghavan
CC BY-SA 4.0
2022-12-06T05:56:58.863Z
2022-12-06T06:01:04.550Z
2022-12-06T06:01:04.550Z
Chakravarti Raghavan
<p>Hi i am building CrowdFund where i need to know the total amount raised at the script as an OnChain validation.
i was looking at Contexts.findOwnInput but would this only return the tx-in's provided in this particular redeem call?
I am looking to get all the unspent UTXOs at the script address and i need that in the OnChain logic and not offChain- so i can total all the Ada to know how much is now at the Script. And if certain target is reached i can allow the Crowd Source owner to take that Ada.
appreciate your thoughts.</p>

CC BY-SA 4.0
2023-01-05T10:52:23.040Z
As far as I know, the on-chain validator does not have access to anything else than what you send it as parameters. So what you want is not possible. You need to do it off-chain.
George - APEX Stake Pool
CC BY-SA 4.0
2023-01-06T23:44:54.207Z
yes thx George! i also realized that later. i think Cause script cannot see whole blockchain but only utXos submitted with the Txn. So i still am working but i think we can use NFT at script to instead use redeem actions to add contributions and that way update datum with target amount. and then i know if total target reached or not.
Chakravarti Raghavan
<utxo><on-chain><script-addresses>
How to get all unSpent UTXOs at script address OnChain
# How to get all unSpent UTXOs at script address OnChain

(Asked by: username_0 on 2022-11-30)

Hi i am building CrowdFund where i need to know the total amount raised at the script as an OnChain validation.
i was looking at Contexts.findOwnInput but would this only return the tx-in's provided in this particular redeem call?
I am looking to get all the unspent UTXOs at the script address and i need that in the OnChain logic and not offChain- so i can total all the Ada to know how much is now at the Script. And if certain target is reached i can allow the Crowd Source owner to take that Ada.
appreciate your thoughts.

**Tags:** utxo, on-chain, script-addresses
> **Comments:**
> **username_1**: As far as I know, the on-chain validator does not have access to anything else than what you send it as parameters. So what you want is not possible. You need to do it off-chain.  
> **username_0**: yes thx George! i also realized that later. i think Cause script cannot see whole blockchain but only utXos submitted with the Txn. So i still am working but i think we can use NFT at script to instead use redeem actions to add contributions and that way update datum with target amount. and then i know if total target reached or not.  

---

## 1 answers

### Answer by username_0 on 2022-12-06. Score: 0

i was actually able to do this:
    txinfo :: Contexts.TxInfo
    txinfo = Contexts.scriptContextTxInfo context

    txInputs = Contexts.txInfoInputs txinfo

    validatedValue = Contexts.txOutValue . Contexts.txInInfoResolved <$> txInputs

With this i was able to get all the UTXOs submitted to the transaction.
It still means the submit transaction need to gather UTXO's and submit it with tx-in to the transaction.
Obviously there might be some limits on how many tx-in you can submit based on the transaction size etc.
But i was able to submit 2 UTXO as tx-in and with Contexts.txInfoInputs was able to get both amounts locked at the script at once.
Contexts.findOwnInput seems to validate 1 at a time even when 2 tx-in are submitted. So i would NOT know the combined value of both UTXOs at this script address.
I would be interested to know whats other solutions are there that could be even better

> **Comments:**
> **username_0**: i realized later i think Cause script cannot see whole blockchain but only utXos submitted with the Txn. So i still am working but i think we can use NFT at script to instead use redeem actions to add contributions and that way update datum with target amount. and then i know if total target reached or not.  

---

