Skip to main content

send

Sends arbitrary scripts, transactions, and requests to Flow.

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

WARNING: 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 fcl from "@onflow/fcl-core"
_10
_10
fcl.send(args, opts)

Or import directly the specific function:


_10
import { send } from "@onflow/fcl-core"
_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:

_10
false | Function | (false | Function)[]

  • Description: An array of builders (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>

A promise that resolves to a ResponseObject containing the data returned from the chain. Should always be decoded with fcl.decode() to get back appropriate JSON keys and values.


Rate this page