Skip to main content

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:


_10
import * as sdk from '@onflow/sdk';
_10
_10
sdk.voucherIntercept(fn);

Or import directly the specific function:


_10
import { voucherIntercept } from '@onflow/sdk';
_10
_10
voucherIntercept(fn);

Usage​


_24
import * as fcl from '@onflow/fcl';
_24
_24
// Intercept voucher for logging
_24
await 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:

_10
type VoucherInterceptFn = (voucher: Voucher) => any | Promise<any>;

  • Description: The function to intercept and potentially modify the voucher

Returns​


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

A function that processes an interaction object


Rate this page