Change custody address

Accounts are owned by custody address which is an Ethereum address on OP Mainnet.

A user may want to change this address for security reasons or to transfer ownership of the entire account.

Requirements

  • An ETH wallet that owns the account on OP Mainnet, with some ETH.
  • An Ethereum provider URL for OP Mainnet (e.g. via Alchemy, Infura or QuickNode).

Change Custody Address

Call the transfer function on the Id Registry contract. The receiving address must provide an EIP-712 signature accepting the transfer.

import { ViemWalletEip712Signer } from '@farcaster/hub-web';
import { walletClient, account } from './clients.ts';
import { readNonce, getDeadline } from './helpers.ts';

const nonce = await readNonce();
const deadline = getDeadline();

const eip712Signer = new ViemWalletEip712Signer(walletClient);
const signature = await eip712signer.signTransfer({
  fid: 1n,
  to: account,
  nonce,
  deadline,
});

const { request: transferRequest } = await publicClient.simulateContract({
  ...IdContract,
  functionName: 'transfer',
  args: [account, deadline, signature], // to, deadline, signature
});

await walletClient.writeContract(transferRequest);

Transferring a FID does not reset its recovery address. To transfer a FID and update its recovery address, call transferAndChangeRecovery.

See the Id Registry section for more details.