> For the complete documentation index, see [llms.txt](/llms.txt).

# Disable a delegation

Delegations are created offchain and can be stored anywhere, but you can disable a delegation onchain using the toolkit. When a delegation is disabled, any attempt to redeem it will revert, effectively revoking the permissions that were previously granted.

For example, if Alice has given permission to Bob to spend 10 USDC on her behalf, and after a week she wants to revoke that permission, Alice can disable the delegation she created for Bob. If Bob tries to redeem the disabled delegation, the transaction will revert, preventing him from spending Alice's USDC.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

- [Install and set up the Smart Accounts Kit.](/smart-accounts-kit/development/get-started/install/)
- [Create a delegator account.](/smart-accounts-kit/development/guides/delegation/execute-on-smart-accounts-behalf/#3-create-a-delegator-account)
- [Create a delegate account.](/smart-accounts-kit/development/guides/delegation/execute-on-smart-accounts-behalf/#4-create-a-delegate-account)

## Disable a delegation[​](#disable-a-delegation-1 "Direct link to Disable a delegation")

To disable a delegation, you can use the [disableDelegation](/smart-accounts-kit/development/reference/delegation/#disabledelegation) utility function from the toolkit to generate calldata. Once the calldata is prepared, you can send it to the [Delegation Manager](/smart-accounts-kit/development/reference/glossary#delegation-manager)**Delegation Manager** The ERC-7710 component that validates and redeems delegations, including signature checks and caveat enforcer hooks. to disable the delegation.

- example.ts
- config.ts

```
import { DelegationManager } from '@metamask/smart-accounts-kit/contracts'
import { environment, delegation, bundlerClient } from './config.ts'

const disableDelegationData = DelegationManager.encode.disableDelegation({
  delegation,
})

// Appropriate fee per gas must be determined for the specific bundler being used.
const maxFeePerGas = 1n
const maxPriorityFeePerGas = 1n

const userOperationHash = await bundlerClient.sendUserOperation({
  account: delegatorAccount,
  calls: [
    {
      to: environment.DelegationManager,
      data: disableDelegationData,
    },
  ],
  maxFeePerGas,
  maxPriorityFeePerGas,
})

```

```
import { sepolia as chain } from 'viem/chains'
import { createPublicClient, http, parseEther } from 'viem'
import { createBundlerClient } from 'viem/account-abstraction'
import {
  getSmartAccountsEnvironment,
  createDelegation,
  ScopeType,
} from '@metamask/smart-accounts-kit'

export const environment = getSmartAccountsEnvironment(chain.id)

const currentTime = Math.floor(Date.now() / 1000)

export const delegation = createDelegation({
  scope: {
    type: ScopeType.NativeTokenPeriodTransfer,
    periodAmount: parseEther('0.01'),
    periodDuration: 86400,
    startDate: currentTime,
  },
  to: delegateAccount,
  from: delegatorAccount,
  environment: delegatorAccount.environment,
})

const publicClient = createPublicClient({
  chain,
  transport: http(),
})

export const bundlerClient = createBundlerClient({
  client: publicClient,
  transport: http('https://api.pimlico.io/v2/11155111/rpc?apikey=<YOUR-API-KEY>'),
})

```
