Actalink Docs
Usage/Acta payments

Cancel all Programmable transfers

Steps to Cancel Recurring Transfers

Create wagmi config

In the first step, create a Wagmi configuration file.

src/wagmi.ts
 
import { http, createConfig } from "wagmi";
import { polygon } from "wagmi/chains";
 
export const config = createConfig({
chains: [polygon],
transports: {
[polygon.id]: http(),
},
});
Projects built with Rainbowkit can utilize Rainbowkit's default Wagmi configuration.

Cancel Recurring Transfers

Use the useCancel() and useSIWE() hooks to cancel all recurring transfers. Any unprocessed scheduled recurring transfers will be marked as cancelled on the paymaster.

src/pages/index.tsx
import {useAccount} from "wagmi";
import { useActaAccount, useFees, useMerkleSignUserOps, useSalt, type BodyType } from "@actalink/react-hooks";
import { config } from "../wagmi";
 
export default function Home() {
 
	const PAYMASTER_URL = "<paymaster url>";
 
  const { address: eoaAddress, status: eoaStatus, chainId } = useAccount();
 
  const { salt } = useSalt({ eoaAddress, eoaStatus, config }); // this hook generates a unique salt using wallet signature
 
  const validators = ["0x", "0x"]; // use your own validators
 
  const { address: swAddress, status: swStatus, actaAccount } = useActaAccount({ eoaAddress, eoaStatus, chainId, config, validators });
 
  console.log(swAddress);
 
  const { fetchSIWEToken } = useSIWE({ eoaAddress: eoaAddress, eoaStatus: eoaStatus, chainId: chainId, config});
 
  const { cancel } = useCancel();
 
  const cancelPendingTransactions = async () => {
    const token = await fetchSIWEToken(PAYMASTER_URL);
    if (token) {
      if (salt) {
        const body = {
          validators: validators,
          salt,
        };
        await cancel(token.token as string, body as BodyType, PAYMASTER_URL);
      }
    }
  };
 	return ()
}

After invoking the cancel() method from the useCancel() hook, all scheduled recurring transfers will be canceled.

👏 Congratulations! You have successfully canceled the scheduled recurring transfers.

On this page