authz
A convenience method that produces the needed authorization details for the current user to submit transactions to Flow. It defines a signing function that connects to a user's wallet provider to produce signatures to submit transactions.
You can replace this function with your own authorization function if needed.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl"_10_10fcl.authz()
Or import directly the specific function:
_10import { authz } from "@onflow/fcl"_10_10authz()
Usage
_22import * as fcl from '@onflow/fcl';_22// login somewhere before_22fcl.authenticate();_22// once logged in authz will produce values_22console.log(fcl.authz);_22// prints {addr, signingFunction, keyId, sequenceNum} from the current authenticated user._22_22const txId = await fcl.mutate({_22  cadence: `_22    import Profile from 0xba1132bc08f82fe2_22_22    transaction(name: String) {_22      prepare(account: auth(BorrowValue) &Account) {_22        account.storage.borrow<&{Profile.Owner}>(from: Profile.privatePath)!.setName(name)_22      }_22    }_22  `,_22  args: (arg, t) => [arg('myName', t.String)],_22  proposer: fcl.authz, // optional - default is fcl.authz_22  payer: fcl.authz, // optional - default is fcl.authz_22  authorizations: [fcl.authz], // optional - default is [fcl.authz]_22});
Returns
_10(account: Account) => Promise<Account>
An object containing the necessary details from the current user to authorize a transaction in any role.