contracts icon indicating copy to clipboard operation
contracts copied to clipboard

Proof-of-concept ERC721 Bridge Implementation

Open azf20 opened this issue 4 years ago • 5 comments

Description

  • This introduces an example ERC721 bridging implementation
  • The base ERC721 contracts are slightly amended from OpenZeppelin's latest implementation of the standard
  • There is an assumption in the existing ERC20 implementation that the source contract will always be on L1, with tokens depositing to L2. The naming convention in this ERC721 implementation doesn't make an assumption which side (Gateway / Deposited) is on L1 and which is on L2
  • This implementation makes the assumption that the source ERC721 contract has implemented the optional Metadata standard and so implements function tokenURI(uint256 _tokenId) external view returns (string); (this is implemented at the Abstract contract level)

Additionally this adds init() tests to the DepositedERC20 contract as they were quite transferable.

Questions

  • I tried to follow the patterns implemented for the ERC20 bridge as closely as possible
  • The OpenZeppelin ERC721 implementation is quite a lot heavier than the UniswapV2 standard used for ERC20 in this repo. Open to amending or slimming this down if there are other preferred reference implementations.
  • I had an issue setting bytes on smoddit, it seems like that is currently unsupported?

Metadata

Contributing Agreement

azf20 avatar Mar 14 '21 14:03 azf20

Had to increase Default Withdrawal Gas on DepositedERC721 for this to work with the origin contract on L2. Not sure what the ramifications of that might be, comments welcome.

azf20 avatar Mar 15 '21 00:03 azf20

Hey thank you for this. I'll take a look this week!

maurelian avatar Mar 22 '21 16:03 maurelian

Any updates on this?

platocrat avatar Apr 05 '21 16:04 platocrat

I have added onERC721Received support to the gateway (cc @wighawag ), though I couldn't get the smocked Messenger to support it in the tests to check the message as in the other deposit tests. I have verified that it works as intended in an integration branch (https://github.com/austintgriffith/scaffold-eth/tree/oo-wip), so not sure if it is my user error, or something with smocked when it is called as the result of a callback:

const depositCallToMessenger =
        Mock__OVM_L1CrossDomainMessenger.smocked.sendMessage.calls[0]

in the new test throws with: TypeError: Cannot read property 'map' of undefined

@platocrat & @maurelian not sure where this ended up (as I know there was a thread on bridging and the preferred approach there), happy to adjust this accordingly

azf20 avatar Apr 06 '21 21:04 azf20

Fixed the smocked issue (with thanks to @smartcontracts see more here)

azf20 avatar Apr 07 '21 21:04 azf20