voucherIntercept
A builder function that intercepts and modifies a voucher.
This function is useful for debugging, logging, or making modifications to the transaction data. The voucher contains all the transaction details in their final form.
Import
You can import the entire package and access the function:
_10import * as sdk from '@onflow/sdk';_10_10sdk.voucherIntercept(fn);
Or import directly the specific function:
_10import { voucherIntercept } from '@onflow/sdk';_10_10voucherIntercept(fn);
Usage
_24import * as fcl from '@onflow/fcl';_24_24// Intercept voucher for logging_24await fcl.send([_24  fcl.transaction`_24    transaction {_24      prepare(account: AuthAccount) {_24        log("Transaction executed")_24      }_24    }_24  `,_24  fcl.voucherIntercept((voucher) => {_24    console.log('Voucher details:', {_24      cadence: voucher.cadence,_24      proposalKey: voucher.proposalKey,_24      payer: voucher.payer,_24      authorizers: voucher.authorizers,_24      computeLimit: voucher.computeLimit,_24    });_24  }),_24  fcl.proposer(fcl.authz),_24  fcl.payer(fcl.authz),_24  fcl.authorizations([fcl.authz]),_24]);
Parameters
fn
- Type:
 
_10type VoucherInterceptFn = (voucher: Voucher) => any | Promise<any>;
- Description: The function to intercept and potentially modify the voucher
 
Returns
_10export type InteractionBuilderFn = (_10  ix: Interaction,_10) => Interaction | Promise<Interaction>;
A function that processes an interaction object