Skip to main content

query.provider.resolvescriptref

Home > @blaze-cardano/query > Provider > resolveScriptRef

Provider.resolveScriptRef() method

Resolves the script deployment by finding a UTxO containing the script reference.

Signature:

resolveScriptRef(script: Script | Hash28ByteBase16, address?: Address): Promise<TransactionUnspentOutput | undefined>;

Parameters

Parameter

Type

Description

script

Script | Hash28ByteBase16

The script or its hash to resolve.

address

Address

(Optional) The address to search for the script deployment. Defaults to a burn address.

Returns:

Promise<TransactionUnspentOutput | undefined>

{Promise<TransactionUnspentOutput | undefined>} - The UTxO containing the script reference, or undefined if not found.

Remarks

This is a default implementation that works but may not be optimal. Subclasses of Provider should implement their own version for better performance.

The method searches for a UTxO at the given address (or a burn address by default) that contains a script reference matching the provided script or script hash.

Example

const scriptUtxo = await provider.resolveScriptRef(myScript);
if (scriptUtxo) {
console.log("Script found in UTxO:", scriptUtxo.input().toCore());
} else {
console.log("Script not found");
}