Some EIPs, in particular EIP721 and EIP1155, have functions like
safeMint that allow to check if the recipient is “capable” of receiving NFTs. In order to know what behavior to adopt, the function first checks if the recipient has bytecode at its address, if not it’s a regular account, otherwise a smart-contract and then proceeds with its check.
This pattern is broke with Starknet because “regular” accounts are smart-contracts as well.
What we can do
I believe we, as a community, should have a discussion about how to fix this issue.
My first thought was trying to call
get_nonce() on the recipient, but it dawned on me that if the recipient doesn’t have that function, i.e. it’s not an account, the whole transaction will revert, making it impossible to continue further.
For the moment, until we have better internal calls management, the only solution I see would be to drop these functions, breaking with the EIPs.
Taking ERC721 as an example, I thought the whole purpose of the contract check is to then be able to run
onERC721Received (see below). If all accounts are contracts, could we just skip the contract check step and go straight to
/// @notice Transfers the ownership of an NFT from one address to another address
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT. Throws if `_from` is
/// not the current owner. Throws if `_to` is the zero address. Throws if
/// `_tokenId` is not a valid NFT. When transfer is complete, this function
/// checks if `_to` is a smart contract (code size > 0). If so, it calls
/// `onERC721Received` on `_to` and throws if the return value is not
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
/// @param data Additional data with no specified format, sent in call to `_to`
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
Well, this check is there to be sure that the recipient smart-contract was actually written with the ability to handle NFTs. The same issue exists on Starknet ; contracts not able to handle NFTs, beside Accounts.