run
Runs a set of functions on an interaction
This is a utility function for testing that builds and resolves an interaction with the provided builder functions. It automatically adds a reference block and then resolves the interaction for testing purposes.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.run(fns)
Or import directly the specific function:
_10import { run } from "@onflow/sdk"_10_10run(fns)
Usage
_28import { run } from "@onflow/sdk"_28import * as fcl from "@onflow/fcl";_28_28// Test a simple script interaction_28const result = await run([_28 fcl.script`_28 access(all) fun main(): Int {_28 return 42_28 }_28 `_28]);_28_28console.log(result.cadence); // The Cadence script_28console.log(result.tag); // "SCRIPT"_28_28// Test a transaction with arguments_28const txResult = await run([_28 fcl.transaction`_28 transaction(amount: UFix64) {_28 prepare(account: AuthAccount) {_28 log(amount)_28 }_28 }_28 `,_28 fcl.args([fcl.arg("10.0", fcl.t.UFix64)])_28]);_28_28console.log(txResult.message.arguments); // The resolved arguments
Parameters
fns
(optional)
- Type:
((ix: Interaction) => Interaction | Promise<Interaction>)[]
- Description: An array of functions to run on the interaction