0

Hi i have noticed that you can get the unspent UTxOs in an wallet address using the Ledger. Constraints module. I want to know can I use it the same in the mkValidator as in the Endpoints?

The general form of the question is can I query the CLI node inside the validator, and make custom validation logic using the received information?

2 Answers 2

1

In short: no.

Validator has three arguments:

  • datum, from the utxo considered
  • redemeer, supplied in the tx
  • script context, which is a collection of data about the tx.

Nothing else.

Any information the validator needs must be supplied somehow in the arguments.

Some Ledger.Constraints can be used in validator logic. (Here)

These are used in some of the examples provided. For example https://github.com/input-output-hk/plutus-apps/blob/13836ecf59649ca522471417b07fb095556eb981/plutus-use-cases/src/Plutus/Contracts/MultiSigStateMachine.hs#L225

2
  • Can i call the function to check the UTxOs at the address signing the transaction?
    – KryptoKing
    Commented Feb 28, 2022 at 9:21
  • 1
    No. Not unless they are used in the Tx.
    – waalge
    Commented Feb 28, 2022 at 11:01
0

Okay After some studying and testing on the playground the answer is a yes. Whilst the Ledger.Constraints can not be taken as an input to the smart contract, it can be called from the validator part of the code, not just the Endpoints.

The exception is that if you have multiple smart contracts in a single Dapp the output of the first could be the input to the second. This would allow you to call Ledger.Constraints from the first contract and have the data readily available in the second.

You can use the Ledger.Contract module to query the chain, but it's limited and unstable. I am currently writing the CIP to fix this, so you may be able to do this easily and efficiently at the time of reading, but not writing.

Below is a link to a conversation with the plutus team on this topic: https://github.com/input-output-hk/plutus-apps/issues/339

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.