As the title says, is there a way for the smart contract to read all UTxOs on its own address and also verify that all UTxOs were used to determine token count on the address.

For example users send funds to the SC address, each in their own utxo as they don't interact with the script. When the total funds (all UTxOs combined) hit a specific amount, you are allowed to withdraw them.

3 Answers 3


is there a way for the smart contract to read all UTxOs on its own address

No. The transaction submitter can pick and choose which UTxOs to include in the transaction (which UTxOs will be visible to the script).

However, you can write the script in a way that requires a certain set of UTxOs be include in the redeeming transactions.

Hope that helps.


In the off-chain code, you probably want to use the Contract monad. In the on-chain code (validator), you can use TxInfo. So, for each TxOut given by txInfoOutputs you can use txOutValue to get the address, and on that value, you can run valueOf to get the number of Ada or whichever token you are trying to compare the value of. From that, just pop it into the validator and have it throw an error if it is beneath your specified value.


  • Thanks. Your answer made me realize that I have to rephrase my question. Please see my edit.
    – Xiaofei
    Sep 16, 2021 at 20:45

While building your transaction on the off-chain code, you can instruct it to consume all the utxos at a certain address (it can be your SC address).

Then in your smart contract on-chain, you can access these utxos from TxInfo of your Context.

From there you can access the value inside each of those utxos, do your math and act accordingly.

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.