isDelegatedTo method

Future<bool> isDelegatedTo(
  1. EthereumAddress eoa,
  2. EthereumAddress impl
)

Checks whether the given externally owned account (EOA) is currently delegated to the specified implementation address.

This method reads the EOA’s code via getDelegatedImpl. If the code contains a valid EIP-7702 delegation stub, the extracted 20-byte implementation address is compared to the provided impl.

Returns:

  • true if the EOA delegates to impl.
  • false if the EOA has no delegation stub or delegates elsewhere.

Example:

final isActive = await isDelegatedTo(myEoa, implAddress);
if (isActive) {
  print('Delegation is already set.');
}

See also:

Implementation

Future<bool> isDelegatedTo(EthereumAddress eoa, EthereumAddress impl) async {
  final currentImpl = await getDelegatedImpl(eoa);
  if (currentImpl == null) return false;
  return bytesToHex(currentImpl) == impl.without0x;
}