Spend Validator
Detailed guide on spend validators including overview, use cases, and example Anvil API interactions.
Overview
Spend validators control the conditions under which UTXOs can be spent from script addresses.
Real-world Use Cases
Asset Locking: Define conditions for when locked assets can be accessed
Multi-signature Schemes: Require approval from multiple parties
Time-locked Funds: Allow access only after certain time conditions
Conditional Payments: Release funds when specific on-chain/off-chain conditions are met
Required UTxO Fields and Deployed Blueprint
PREREQUISITE: DEPLOYED SMART CONTRACT
Before you can interact with any validator, you must have a compiled and deployed smart contract blueprint. The validator hash used in these examples comes from your deployed blueprint.
Refer to the Blueprint Management guide for details on how to deploy your smart contract blueprint.
Don't forget to lock assets at the script address in a prior transaction. Then when spending, specify the locked UTxO using the outputRef field, which pinpoints the UTxO by its transaction hash and output index.
{
"txHash": "transaction_hash", // Transaction hash where funds were locked
"index": 0 // Output index within that transaction
}Anvil API returns the UTXOs in the order they were added when you previously locked the assets.
Spend Validator API Interaction Example
Use the below examples to build transactions that interact with the spend validator.
If you are unfamiliar with the Anvil API transaction builder, review the Transaction Overview guide first.
1. Locking Assets at Script Address
2. Spending (Unlocking) Locked UTxO
See Examples
https://github.com/Cardano-Forge/anvil-api/blob/main/docs/guides/hello-world-smart-contract.mdhttps://github.com/Cardano-Forge/anvil-api/blob/main/docs/guides/escrow/README.mdLast updated
Was this helpful?

