<p>Okay After some studying and testing on the playground the answer is a yes.
Whilst the <code>Ledger.Constraints</code> 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.</p>
<p>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 <code>Ledger.Constraints</code> from the first contract and have the data readily available in the second.</p>
<p>You can use the <code>Ledger.Contract</code> 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.</p>
<p>Below is a link to a conversation with the plutus team on this topic: <a href="https://github.com/input-output-hk/plutus-apps/issues/339" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus-apps/issues/339</a></p>

CC BY-SA 4.0
2022-03-03T08:10:08.350Z
2022-03-11T15:47:24.297Z
2022-03-11T15:47:24.297Z
KryptoKing
<p>In short: no.</p>
<p>Validator has three arguments:</p>
<ul>
<li>datum, from the utxo considered</li>
<li>redemeer, supplied in the tx</li>
<li>script context, which is a collection of data about the tx.</li>
</ul>
<p>Nothing else.</p>
<p>Any information the validator needs must be supplied somehow in the arguments.</p>
<p>Some <code>Ledger.Constraints</code> can be used in validator logic.
(<a href="https://github.com/input-output-hk/plutus-apps/blob/46e831e49287c3a04f83497b9dd9e70718092cde/plutus-ledger-constraints/src/Ledger/Constraints/TxConstraints.hs#L42" rel="nofollow noreferrer">Here</a>)</p>
<p>These are used in some of the examples provided. For example
<a href="https://github.com/input-output-hk/plutus-apps/blob/13836ecf59649ca522471417b07fb095556eb981/plutus-use-cases/src/Plutus/Contracts/MultiSigStateMachine.hs#L225" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus-apps/blob/13836ecf59649ca522471417b07fb095556eb981/plutus-use-cases/src/Plutus/Contracts/MultiSigStateMachine.hs#L225</a></p>

CC BY-SA 4.0
2022-02-28T09:21:21.580Z
Can i call the function to check the UTxOs at the address signing the transaction?
KryptoKing
CC BY-SA 4.0
2022-02-28T11:01:22.287Z
No. Not unless they are used in the Tx.
waalge
CC BY-SA 4.0
2022-02-28T08:52:06.893Z
2022-02-28T08:52:06.893Z
waalge
<p>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?</p>
<p>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?</p>

<plutus><plutus-pioneer-program><validator><smart-contract>
How can you use Ledger.Constraints in the Validator?
# How can you use Ledger.Constraints in the Validator?

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

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?

**Tags:** plutus, plutus-pioneer-program, validator, smart-contract

---

## 2 answers

### Answer by username_0 on 2022-03-03. Score: 0 | Accepted answer

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>


---

### Answer by username_1 on 2022-02-28. Score: 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](https://github.com/input-output-hk/plutus-apps/blob/46e831e49287c3a04f83497b9dd9e70718092cde/plutus-ledger-constraints/src/Ledger/Constraints/TxConstraints.hs#L42))

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>

> **Comments:**
> **username_0**: Can i call the function to check the UTxOs at the address signing the transaction?  
> **username_1**: No. Not unless they are used in the Tx.  

---

