Skip to main content

Wallet Client actions reference

These actions extend the Viem Wallet Client to support ERC-7710 utilities.

sendTransactionWithDelegation

Sends a transaction to redeem delegated permissions according to the ERC-7710 specifications.

info

To use sendTransactionWithDelegation, the Viem Wallet Client must be extended with erc7710WalletActions.

Parameters

See the Viem sendTransaction parameters. This function has the same parameters, and it also requires the following parameters:

NameTypeRequiredDescription
delegationManagerAddressYesThe address of the Delegation ManagerDelegation Manager The ERC-7710 component that validates and redeems delegations, including signature checks and caveat enforcer hooks..
permissionContextPermissionContextYesAn encoded delegation chain (Hex) or a decoded delegation chain (Delegation[]) for redeeming delegations.

Example

import { walletClient, publicClient } from './client.ts'

// These properties must be extracted from the permission response. See
// `grantPermissions` action to learn how to request permissions.
const permissionContext = permissionsResponse[0].context
const delegationManager = permissionsResponse[0].signerMeta.delegationManager

const hash = walletClient.sendTransactionWithDelegation({
chain,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1n,
permissionContext,
delegationManager,
})

redelegatePermissionContext

Creates a redelegationRedelegation A delegation that passes on authority granted by a previous delegation. to a specific delegateDelegate account The account that receives delegated authority and can redeem a delegation under its constraints. from a delegation chain encoded as Hex or decoded as Delegation[].

The action returns RedelegatePermissionContextReturnType.

Parameters

NameTypeRequiredDescription
environmentSmartAccountsEnvironmentYesContract addresses for the Delegation FrameworkDelegation Framework A set of audited smart contracts that handle smart account creation, the delegation lifecycle, and caveat enforcement. on the target chain.
permissionContextPermissionContextYesEncoded delegation chain (Hex) or decoded chain (Delegation[]), leaf first.
chainIdnumberNoChain ID used when signing the delegation.
accountAccount | AddressNoAccount that signs the redelegation. The default is the Wallet Client's configured account.
scopeScopeConfigNoDelegation scopeDelegation scope A predefined authority pattern representing a caveat or group of caveats, which sets the initial actions a delegate is allowed to perform. You can combine scopes with additional caveats. to restrict the authority of the redelegation.
caveatsCaveatsNoAdditional caveatsCaveat A restriction attached to a delegation that limits how delegated authority can be used. to restrict the authority of the redelegation. See caveats reference.
saltHexNoSalt for redelegation.
toAddressYesAddress of the delegate for the redelegation.

Example

import { walletClient, publicClient, environment } from './client.ts'

// These properties must be extracted from the permission response. See
// `grantPermissions` action to learn how to request permissions.
const permissionContext = permissionsResponse[0].context

const { permissionContext: redelegatedPermissionContext } =
walletClient.redelegatePermissionContext({
to: 'DELEGATE_ADDRESS',
environment,
permissionContext: permissionContext,
})

redelegatePermissionContextOpen

Creates an open redelegationOpen redelegation A redelegation with no specific delegate, allowing any account to redeem inherited permissions. from a delegation chain encoded as Hex or decoded as Delegation[]. This allows any account to redeem the inherited permissions.

The action returns RedelegatePermissionContextReturnType.

Parameters

NameTypeRequiredDescription
environmentSmartAccountsEnvironmentYesContract addresses for the Delegation FrameworkDelegation Framework A set of audited smart contracts that handle smart account creation, the delegation lifecycle, and caveat enforcement. on the target chain.
permissionContextPermissionContextYesEncoded delegation chain (Hex) or decoded chain (Delegation[]), leaf first.
chainIdnumberNoChain ID used when signing the delegation.
accountAccount | AddressNoAccount that signs the redelegation. The default is the Wallet Client's configured account.
scopeScopeConfigNoDelegation scopeDelegation scope A predefined authority pattern representing a caveat or group of caveats, which sets the initial actions a delegate is allowed to perform. You can combine scopes with additional caveats. to restrict the authority of the redelegation.
caveatsCaveatsNoAdditional caveatsCaveat A restriction attached to a delegation that limits how delegated authority can be used. to restrict the authority of the redelegation. See caveats reference.
saltHexNoSalt for redelegation.

Example

import { walletClient, publicClient, environment } from './client.ts'

// These properties must be extracted from the permission response. See
// `grantPermissions` action to learn how to request permissions.
const permissionContext = permissionsResponse[0].context

const { permissionContext: redelegatedPermissionContext } =
walletClient.redelegatePermissionContextOpen({
environment,
permissionContext: permissionContext,
})