Skip to main content

args

A utility builder to be used with other builders to pass in arguments with a value and supported type.

A transaction can accept zero or more arguments that are passed into the Cadence script. The arguments on the transaction 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.args(ax)

Or import directly the specific function:


_10
import { args } from "@onflow/sdk"
_10
_10
args(ax)

Usage


_15
import * as fcl from "@onflow/fcl"
_15
_15
await fcl.mutate({
_15
cadence: `
_15
transaction(amount: UFix64, to: Address) {
_15
prepare(signer: AuthAccount) {
_15
// transaction logic
_15
}
_15
}
_15
`,
_15
args: (arg, t) => [
_15
arg("10.0", t.UFix64), // Will be the first argument `amount: UFix64`
_15
arg("0xba1132bc08f82fe2", t.Address), // Will be the second argument `to: Address`
_15
],
_15
})

Parameters

ax

  • Type: CadenceArgument
  • Description: An array of arguments

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

Returns

InteractionBuilderFn


_10
export type InteractionBuilderFn = (
_10
ix: Interaction
_10
) => Interaction | Promise<Interaction>


Rate this page