loomnetwork / erc721x

ERC721x is an extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible.
BSD 3-Clause "New" or "Revised" License
165 stars 54 forks source link

Several issues with ERC721 standard #15

Closed wighawag closed 6 years ago

wighawag commented 6 years ago

The current implementation do not respect ERC721 standard

event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); This event should always be emitted, regardless of how the actual transfer of balance happen.

In the current implementation it is only emitted when using the ERC721 transfers methods (the one who do not specify quantity)

It should be emitted also when doing ERC721x transfers, including Batch transfers

Other potential issues

In the current implementation

Regarding naming, I suggest calling it : TransferWithQuantity or at least something less generic than TransferToken

There also few function mentioned on github as part of the interface but not implemented

Lastly this one is implemented but return 0

gakonst commented 6 years ago

Thank you for all the issues you have found in the implementation :)

event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); This event should always be emitted, regardless of how the actual transfer of balance happen. In the current implementation it is only emitted when using the ERC721 transfers methods (the one who do not specify quantity) It should be emitted also when doing ERC721x transfers, including Batch transfers

I'm not sure I agree here, ERC721 Transfer events should be only regarding NFTs in the contract

event TransferToken is emiited even for NFT when quantity is 1. Should it not be only emitted for FT ?

Fixed in a previous commit, _transferFrom with quantity is now only callable on FTs.

Agree with the TransferWithQuantity, changed. When doing a batch transfer we just a emit a batchTransfer event for all arguments together, firing a Transfer/TransferWithQuantity wouldn't be feasible, as it's 2k extra gas per emission.

Regarding tokenName and individualSupply, the README was outdated, updated now.

tokenOfOwnerByIndex Would that not confuse wallet and tools supporting ERC721 Enumerable extension

Agree, however adding the enumerable extension removes any gains introduced by batch transfers. IMHO the enumerable extension is not necessary and with proper event indexing the data should be retrievable.

wighawag commented 6 years ago

ERC721 Transfer events should be only regarding NFTs in the contract

Sorry if it was not clear but that is exactly my thoughts. I was referring to ERC721 NFT only. As it stands, the Transfer event is not triggered when such NFT is transfered to another owner if the method used is different than the ERC721 transfer function (the one that does not specify quantity) More precisely:

This means the contract is not ERC721 compliant.

When doing a batch transfer we just a emit a batchTransfer event for all arguments together, firing a Transfer/TransferWithQuantity wouldn't be feasible, as it's 2k extra gas per emission.

I understand (though you just need Transfer events to be compliant and not the TransferWithQuantity) but if the Transfer event is not sent for NFT transfer, the Contract will not be implementing ERC721, by definition.

What this means, is that if an application supports ERC721 only (no enumeration extension), there would be no way for that application to keep track of ownership (since Transfer event is not emitted for all case) of ERC721x's NFTs

Agree, however adding the enumerable extension removes any gains introduced by batch transfers. IMHO the enumerable extension is not necessary ...

Would it not better to remove the function entirely and not try to be compliant with the enumerable extension then? Do you plan to add ERC165 supportInterface function (you would need to be ERC721 compliant) ? If so you do not need to return true for 0x780e9d63 (ERC721Enumerable)

... and with proper event indexing the data should be retrievable.

As mentioned above, if the ERC721 Transfer event is not emitted for all NFT transfer (regardless of the method invoked), an application supporting ERC721 only would not be able to use events to track the data

gakonst commented 6 years ago

Emitting a Transfer event now during batch transfers if the token is a NFT in https://github.com/loomnetwork/erc721x/commit/265c3368425cd3d75f0bf5618123e9f7ee249b38. Will consider removing the Enumerable extension