Skip to main content

InteractionTemplateUtils

Overview

Namespace containing InteractionTemplateUtils utilities

Functions

deriveCadenceByNetwork

Fills import addresses in Cadence for network

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.deriveCadenceByNetwork(deriveCadenceByNetworkParams)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.deriveCadenceByNetwork(deriveCadenceByNetworkParams)

Parameters

deriveCadenceByNetworkParams
  • Type:

_10
export interface DeriveCadenceByNetworkParams {
_10
network: string
_10
template: InteractionTemplate
_10
}

Returns

Promise<string>

generateDependencyPin

Generates a dependency pin for a smart contract on the Flow blockchain. A dependency pin is a cryptographic hash that uniquely identifies a specific version of a contract at a particular state. This is used in Interaction Templates to ensure consistent behavior by pinning to specific contract versions and preventing issues from contract updates.

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.generateDependencyPin(generateDependencyPinParams, opts)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.generateDependencyPin(generateDependencyPinParams, opts)

Usage


_10
// Generate dependency pin for a contract at current state
_10
import * as fcl from "@onflow/fcl"
_10
_10
const dependencyPin = await fcl.InteractionTemplateUtils.generateDependencyPin({
_10
version: "1.1.0",
_10
address: "0x1654653399040a61",
_10
contractName: "FlowToken"
_10
})

Parameters

generateDependencyPinParams
  • Type:

_10
export interface GenerateDependencyPinParams {
_10
address: string
_10
contractName: string
_10
blockHeight: number
_10
}

opts (optional)
  • Type: any
  • Description: Additional options to pass to the underlying interaction

Returns

Promise<string>

generateDependencyPinAtLatestSealedBlock

Generates a dependency pin for a smart contract at the latest sealed block on the Flow blockchain. This variant ensures the pin is generated against the most recent finalized state of the network, providing consistency and avoiding issues with pending transactions affecting the pin generation.

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.generateDependencyPinAtLatestSealedBlock(generateDependencyPinParams, opts)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.generateDependencyPinAtLatestSealedBlock(generateDependencyPinParams, opts)

Usage


_10
// Generate dependency pin at latest sealed block
_10
import * as fcl from "@onflow/fcl"
_10
_10
const dependencyPin = await fcl.InteractionTemplateUtils.generateDependencyPinAtLatestSealedBlock({
_10
version: "1.1.0",
_10
address: "0x1654653399040a61",
_10
contractName: "FlowToken"
_10
})

Parameters

generateDependencyPinParams
  • Type:

_10
export interface GenerateDependencyPinParams {
_10
address: string
_10
contractName: string
_10
blockHeight: number
_10
}

opts (optional)
  • Type: any
  • Description: Additional options to pass to the underlying interaction

Returns

Promise<string>

generateTemplateId

Generates Interaction Template ID for a given Interaction Template

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.generateTemplateId(interactionTemplate)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.generateTemplateId(interactionTemplate)

Parameters

interactionTemplate
  • Type:

_10
{ template: InteractionTemplate; }

Returns

Promise<string>

getInteractionTemplateAudits

Checks whether a set of auditors have audited a given Interaction Template on the Flow blockchain. This function validates that the provided interaction template has been properly audited for security by trusted auditors before execution. It queries the Flow blockchain's audit contract to verify audit status.

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.getInteractionTemplateAudits(getInteractionTemplateAuditsParams, opts)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.getInteractionTemplateAudits(getInteractionTemplateAuditsParams, opts)

Usage


_26
// Check if template has been audited by specific auditors
_26
import * as fcl from "@onflow/fcl"
_26
_26
const template = {
_26
f_type: "InteractionTemplate",
_26
f_version: "1.1.0",
_26
id: "template-id-123",
_26
data: {
_26
type: "transaction",
_26
interface: "...",
_26
cadence: "transaction { ... }"
_26
}
_26
}
_26
_26
const auditorAddresses = [
_26
"0x1234567890abcdef",
_26
"0xabcdef1234567890"
_26
]
_26
_26
const auditResults = await fcl.InteractionTemplateUtils.getInteractionTemplateAudits({
_26
template,
_26
auditors: auditorAddresses
_26
})
_26
_26
console.log(auditResults)
_26
// { "0x1234567890abcdef": true, "0xabcdef1234567890": false }

Parameters

getInteractionTemplateAuditsParams
  • Type:

_10
export interface GetInteractionTemplateAuditsParams {
_10
template: InteractionTemplate
_10
auditors?: string[]
_10
}

opts (optional)
  • Type:

_10
export interface GetInteractionTemplateAuditsOpts {
_10
flowInteractionAuditContract?: string
_10
}

  • Description: Optional configuration parameters

Returns

Promise<Record<string, boolean>>

getTemplateArgumentMessage

Gets Interaction Template argument message by message key, argument label, and localization

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.getTemplateArgumentMessage(getTemplateArgumentMessageParams)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.getTemplateArgumentMessage(getTemplateArgumentMessageParams)

Parameters

getTemplateArgumentMessageParams
  • Type:

_10
export interface GetTemplateArgumentMessageParams {
_10
localization?: string
_10
argumentLabel: string
_10
messageKey: string
_10
template: InteractionTemplate
_10
}

Returns

string

getTemplateMessage

Get Interaction Template argument message

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.getTemplateMessage(getTemplateMessageParams)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.getTemplateMessage(getTemplateMessageParams)

Parameters

getTemplateMessageParams
  • Type:

_10
export interface GetTemplateMessageParams {
_10
localization?: string
_10
messageKey: string
_10
template: InteractionTemplate
_10
}

Returns

string

verifyDependencyPinsSame

Checks if an Interaction Template's pins match those generated at a block height

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.verifyDependencyPinsSame(verifyDependencyPinsSameParams, opts)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.verifyDependencyPinsSame(verifyDependencyPinsSameParams, opts)

Parameters

verifyDependencyPinsSameParams
  • Type:

_10
export interface VerifyDependencyPinsSameParams {
_10
template: InteractionTemplate
_10
blockHeight?: number
_10
}

opts (optional)
  • Type:

_10
export interface VerifyDependencyPinsSameOpts {
_10
[key: string]: any
_10
}

Returns

Promise<boolean>

verifyDependencyPinsSameAtLatestSealedBlock

Checks if an Interaction Template's pins match those generated at the latest block height

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.verifyDependencyPinsSameAtLatestSealedBlock(verifyDependencyPinsSameAtLatestSealedBlockParams, opts)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.verifyDependencyPinsSameAtLatestSealedBlock(verifyDependencyPinsSameAtLatestSealedBlockParams, opts)

Parameters

verifyDependencyPinsSameAtLatestSealedBlockParams
  • Type:

_10
export interface VerifyDependencyPinsSameAtLatestSealedBlockParams {
_10
template: InteractionTemplate
_10
network: string
_10
}

opts (optional)
  • Type:

_10
export interface VerifyDependencyPinsSameOpts {
_10
[key: string]: any
_10
}

Returns

Promise<boolean>

verifyGeneratedTemplateId

Verifies the given Interaction Template Id has been correctly generated

Import

You can import the entire package and access the function:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.InteractionTemplateUtils.verifyGeneratedTemplateId(interactionTemplate)

Or import the namespace directly:


_10
import { InteractionTemplateUtils } from "@onflow/fcl-core"
_10
_10
InteractionTemplateUtils.verifyGeneratedTemplateId(interactionTemplate)

Parameters

interactionTemplate
  • Type:

_10
{ template: InteractionTemplate; }

Returns

Promise<boolean>