Skip to main content

Wallet Client actions reference

The following actions are related to the Viem Wallet Client used to execute on a MetaMask user's behalf.

info

To use Advanced Permissions (ERC-7715) actions, the Viem Wallet Client must be extended with erc7715ProviderActions.

requestExecutionPermissions

Requests Advanced Permissions from the MetaMask extension account according to the ERC-7715 specification. Returns a RequestExecutionPermissionsReturnType.

Parameters

NameTypeRequiredDescription
chainIdnumberYesThe chain ID on which the permission is being requested.
fromAddressNoThe wallet address to request the permission from.
expirynumberYesThe timestamp (in seconds) by which the permission must expire.
permissionSupportedPermissionParamsYesThe permission to request. The toolkit supports multiple Advanced Permissions types. Set isAdjustmentAllowed to define whether the user can modify the requested permission.
toAddressYesThe account to which the permission will be assigned.

Example

import { sepolia as chain } from "viem/chains";
import { parseUnits } from "viem";
import { walletClient } from "./client.ts";

const currentTime = Math.floor(Date.now() / 1000);
const expiry = currentTime + 604800;

const grantedPermissions = await walletClient.requestExecutionPermissions([{
chainId: chain.id,
expiry,
// The requested permissions will be granted to the
// session account.
to: sessionAccount.address,
permission: {
type: "erc20-token-periodic",
data: {
tokenAddress: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
periodAmount: parseUnits("10", 6),
periodDuration: 86400,
justification: "Permission to transfer 10 USDC every day",
},
isAdjustmentAllowed: true,
},
}]);

getSupportedExecutionPermissions

Returns the Advanced Permissions types that the wallet supports, according to the ERC-7715 specification. Use this to verify the available permission types and supported chains before requesting permissions.

This action takes no parameters and returns a GetSupportedExecutionPermissionsResult.

Example

import { walletClient } from "./client.ts";

const supportedPermissions = await walletClient.getSupportedExecutionPermissions();

getGrantedExecutionPermissions

Returns all previously granted permissions for the connected wallet, according to the ERC-7715 specification.

This action takes no parameters and returns a GetGrantedExecutionPermissionsResult.

Example

import { walletClient } from "./client.ts";

const grantedPermissions = await walletClient.getGrantedExecutionPermissions();