Skip to main content

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:


_10
import * as fcl from "@onflow/fcl"
_10
_10
fcl.authz()

Or import directly the specific function:


_10
import { authz } from "@onflow/fcl"
_10
_10
authz()

Usage


_22
import * as fcl from '@onflow/fcl';
_22
// login somewhere before
_22
fcl.authenticate();
_22
// once logged in authz will produce values
_22
console.log(fcl.authz);
_22
// prints {addr, signingFunction, keyId, sequenceNum} from the current authenticated user.
_22
_22
const 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.


Rate this page