Skip to main content

arg

A utility builder to be used with fcl.args[...] to create FCL supported arguments for interactions.

Arguments are used to pass data to Cadence scripts and transactions. The arguments must match the number and order declared in the Cadence script.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.arg(value, xform)

Or import directly the specific function:


_10
import { arg } from "@onflow/sdk"
_10
_10
arg(value, xform)

Usage


_15
import * as fcl from "@onflow/fcl"
_15
_15
const result = await fcl.query({
_15
cadence: `
_15
access(all) fun main(a: Int, b: Int, addr: Address): Int {
_15
log(addr)
_15
return a + b
_15
}
_15
`,
_15
args: (arg, t) => [
_15
arg(7, t.Int), // a: Int
_15
arg(6, t.Int), // b: Int
_15
arg("0xba1132bc08f82fe2", t.Address), // addr: Address
_15
],
_15
});

Parameters

value

  • Type: TypeDescriptorInput
  • Description: The value of the argument

xform

  • Type: T
  • Description: A function to transform the value (type descriptor)

Returns

CadenceArgument


_10
type CadenceArgument<T extends TypeDescriptor<any, any>> = {
_10
value: TypeDescriptorInput<T>
_10
xform: T
_10
}


Rate this page