isDelegatedTo method
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:
trueif the EOA delegates toimpl.falseif 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:
- getDelegatedImpl – extracts the implementation from the stub.
Implementation
Future<bool> isDelegatedTo(EthereumAddress eoa, EthereumAddress impl) async {
final currentImpl = await getDelegatedImpl(eoa);
if (currentImpl == null) return false;
return bytesToHex(currentImpl) == impl.without0x;
}