Skip to main content

send

Sends arbitrary scripts, transactions, and requests to Flow.

This method consumes an array of functions that are to be resolved and sent. The functions required to be included in the array depend on the interaction that is being built.

Must be used in conjunction with 'fcl.decode(response)' to get back correct keys and all values in JSON.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.send(args, opts)

Or import directly the specific function:


_10
import { send } from "@onflow/sdk"
_10
_10
send(args, opts)

Usage


_18
import * as fcl from "@onflow/fcl";
_18
_18
// a script only needs to resolve the arguments to the script
_18
const response = await fcl.send([fcl.script`${script}`, fcl.args(args)]);
_18
// note: response values are encoded, call await fcl.decode(response) to get JSON
_18
_18
// a transaction requires multiple 'builders' that need to be resolved prior to being sent to the chain - such as setting the authorizations.
_18
const response = await fcl.send([
_18
fcl.transaction`
_18
${transaction}
_18
`,
_18
fcl.args(args),
_18
fcl.proposer(proposer),
_18
fcl.authorizations(authorizations),
_18
fcl.payer(payer),
_18
fcl.limit(9999)
_18
]);
_18
// note: response contains several values

Parameters

args (optional)

  • Type: false | Function | (false | Function)[]
  • Description: An array of functions that take an interaction object and return a new interaction object

opts (optional)

  • Type: any
  • Description: Additional optional options for the request

Returns

Promise<any>


Rate this page