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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.deriveCadenceByNetwork(deriveCadenceByNetworkParams)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.deriveCadenceByNetwork(deriveCadenceByNetworkParams)
Parameters
deriveCadenceByNetworkParams
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.generateDependencyPin(generateDependencyPinParams, opts)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.generateDependencyPin(generateDependencyPinParams, opts)
Usage
_10// Generate dependency pin for a contract at current state_10import * as fcl from "@onflow/fcl"_10_10const dependencyPin = await fcl.InteractionTemplateUtils.generateDependencyPin({_10 version: "1.1.0",_10 address: "0x1654653399040a61",_10 contractName: "FlowToken"_10})
Parameters
generateDependencyPinParams
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.generateDependencyPinAtLatestSealedBlock(generateDependencyPinParams, opts)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.generateDependencyPinAtLatestSealedBlock(generateDependencyPinParams, opts)
Usage
_10// Generate dependency pin at latest sealed block_10import * as fcl from "@onflow/fcl"_10_10const dependencyPin = await fcl.InteractionTemplateUtils.generateDependencyPinAtLatestSealedBlock({_10 version: "1.1.0",_10 address: "0x1654653399040a61",_10 contractName: "FlowToken"_10})
Parameters
generateDependencyPinParams
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.generateTemplateId(interactionTemplate)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.getInteractionTemplateAudits(getInteractionTemplateAuditsParams, opts)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.getInteractionTemplateAudits(getInteractionTemplateAuditsParams, opts)
Usage
_26// Check if template has been audited by specific auditors_26import * as fcl from "@onflow/fcl"_26_26const 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_26const auditorAddresses = [_26 "0x1234567890abcdef",_26 "0xabcdef1234567890"_26]_26_26const auditResults = await fcl.InteractionTemplateUtils.getInteractionTemplateAudits({_26 template,_26 auditors: auditorAddresses_26})_26_26console.log(auditResults)_26// { "0x1234567890abcdef": true, "0xabcdef1234567890": false }
Parameters
getInteractionTemplateAuditsParams
- Type:
_10export interface GetInteractionTemplateAuditsParams {_10 template: InteractionTemplate_10 auditors?: string[]_10}
opts
(optional)
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.getTemplateArgumentMessage(getTemplateArgumentMessageParams)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.getTemplateArgumentMessage(getTemplateArgumentMessageParams)
Parameters
getTemplateArgumentMessageParams
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.getTemplateMessage(getTemplateMessageParams)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.getTemplateMessage(getTemplateMessageParams)
Parameters
getTemplateMessageParams
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.verifyDependencyPinsSame(verifyDependencyPinsSameParams, opts)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.verifyDependencyPinsSame(verifyDependencyPinsSameParams, opts)
Parameters
verifyDependencyPinsSameParams
- Type:
_10export interface VerifyDependencyPinsSameParams {_10 template: InteractionTemplate_10 blockHeight?: number_10}
opts
(optional)
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.verifyDependencyPinsSameAtLatestSealedBlock(verifyDependencyPinsSameAtLatestSealedBlockParams, opts)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.verifyDependencyPinsSameAtLatestSealedBlock(verifyDependencyPinsSameAtLatestSealedBlockParams, opts)
Parameters
verifyDependencyPinsSameAtLatestSealedBlockParams
- Type:
_10export interface VerifyDependencyPinsSameAtLatestSealedBlockParams {_10 template: InteractionTemplate_10 network: string_10}
opts
(optional)
- Type:
_10export 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:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.InteractionTemplateUtils.verifyGeneratedTemplateId(interactionTemplate)
Or import the namespace directly:
_10import { InteractionTemplateUtils } from "@onflow/fcl-core"_10_10InteractionTemplateUtils.verifyGeneratedTemplateId(interactionTemplate)
Parameters
interactionTemplate
- Type:
_10{ template: InteractionTemplate; }
Returns
Promise<boolean>