Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DN404 identification #69

Open
ghost opened this issue Feb 15, 2024 · 3 comments
Open

DN404 identification #69

ghost opened this issue Feb 15, 2024 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 15, 2024

Currently, it would be possible to use staticcall for mirrorERC721 in order to detect if the contract is DN404 however this could also cause an issue with abi.decode since it doesn't catch decoding errors effectively

ethereum/solidity#10381

Therefore, the cleanest method would be supporting an arbitrary value for supportsInterface function

#68

@Vectorized
Copy link
Owner

function _getMirrorERC721(address possibleDN404) internal view returns (address result) {
    assembly {
        mstore(0x00, 0x4ef41efc) // `mirrorERC721()`.
        if and(
            gt(returndatasize(), 0x1f),
            staticcall(gas(), possibleDN404, 0x1c, 0x04, 0x00, 0x20)
        ) {
            // If result is a non-zero address, contract is very likely DN404.
            result := shr(96, mload(0x0c)) 
        }
    }   
}

@ghost
Copy link
Author

ghost commented Feb 15, 2024

@Vectorized Would be great if we have a set of functions like this as a library contract

@Vectorized
Copy link
Owner

Sounds like good suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant