> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neynar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Change recovery address

Accounts can configure a recovery address to protect against the loss of the custody address. The recovery address will change the custody address of the account.

### Requirements

* An ETH wallet that has an FID on OP Mainnet, with some ETH for gas costs.
* An ETH RPC URL for OP Mainnet (e.g. via [Alchemy](https://www.alchemy.com/), [Infura](https://www.infura.io/) or [QuickNode](https://www.quicknode.com/)).

### Change Address

Call the `changeRecovery` function on the Id Registry contract.

```ts [@farcaster/hub-web] theme={"system"}
import { walletClient, account, IdContract } from './clients.ts';

const newRecoveryAddress = '0x...';

const { request: transferRequest } = await walletClient.simulateContract({
  ...IdContract,
  functionName: 'changeRecovery',
  args: [newRecoveryAddress], // New recovery address
});

await walletClient.writeContract(transferRequest);
```

```ts [clients.ts] theme={"system"}
import {
  idRegistryABI,
  ID_REGISTRY_ADDRESS,
} from '@farcaster/hub-web';
import { createWalletClient, createPublicClient, custom, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { optimism } from 'viem/chains';

export const IdContract = {
  abi: idRegistryABI,
  address: ID_REGISTRY_ADDRESS,
  chain: optimism,
};

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

export const walletClient = createWalletClient({
  chain: optimism,
  transport: custom(window.ethereum),
});

// JSON-RPC Account
export const [account] = await walletClient.getAddresses();

// Local Account (use this OR the JSON-RPC account above, not both)
// export const account = privateKeyToAccount('0x...');
```

See the [Id Registry](/farcaster/reference/contracts/reference/id-registry#changerecoveryaddress) section for more
details.
