Files
openzeppelin-contracts/contracts/account/utils/EIP7702Utils.sol
github-actions[bot] 0b0cbe1286 Release v5.4.0 (rc) (#5731)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: ernestognw <ernestognw@gmail.com>
2025-06-18 17:48:29 +02:00

22 lines
726 B
Solidity

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0-rc.0) (account/utils/EIP7702Utils.sol)
pragma solidity ^0.8.20;
/**
* @dev Library with common EIP-7702 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-7702[ERC-7702].
*/
library EIP7702Utils {
bytes3 internal constant EIP7702_PREFIX = 0xef0100;
/**
* @dev Returns the address of the delegate if `account` as an EIP-7702 delegation setup, or address(0) otherwise.
*/
function fetchDelegate(address account) internal view returns (address) {
bytes23 delegation = bytes23(account.code);
return bytes3(delegation) == EIP7702_PREFIX ? address(bytes20(delegation << 24)) : address(0);
}
}