0

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.

2
  • 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. Jan 5, 2023 at 10:52
  • 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. Jan 6, 2023 at 23:44

1 Answer 1

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

1
  • 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. Jan 6, 2023 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.