useClientActions

A hook that allows you to leverage client decorators to execute actions and await them in your UX. This is particularly useful for using Plugins with Modular Accounts.

Import

1import { useClientActions } from "@account-kit/react";

Usage

1import React from "react";
2import { useSmartAccountClient } from "@account-kit/react";
3import { sessionKeyPluginActions } from "@account-kit/smart-contracts";
4import { useClientActions } from "@account-kit/react";
5
6const Foo = () => {
7 const { client } = useSmartAccountClient({
8 type: "MultiOwnerModularAccount",
9 });
10 const { executeAction } = useClientActions({
11 client: client,
12 actions: sessionKeyPluginActions,
13 });
14
15 executeAction({
16 functionName: "isAccountSessionKey",
17 args: [{ key: "0x0" }],
18 });
19};

Parameters

args

UseClientActionsProps<TTransport, TChain, TActions> the hooks arguments highlighted below. ref

args.client

SmartAccountClient the smart account client returned from useSmartAccountClient

args.actions

object the smart account client decorator you want to execute actions from

Returns

UseClientActionsResult<TActions> an object containing methods to execute the actions as well loading and error states ref