onflow / flips

Flow Improvement Proposals
25 stars 23 forks source link

Flow VM Bridge FLIP #233

Closed franklywatson closed 5 months ago

franklywatson commented 8 months ago

Marked this FLIP as proposed

cybercent commented 6 months ago

In order to bridge an NFT or FT from Flow VM to Flow EVM does the developer need to write and deploy a solidity contract on Flow EVM to match his Cadence contract ?

Assuming an NFT was bridged from Flow VM to Flow EVM. If that token changes owners (through a solidity marketplace contract for example) what events would be triggered on Flow? The events/logs on the solidity contract, the NFT transfer events in the Flow NFT standard, both , or some others ?

sisyphusSmiling commented 6 months ago

In order for a user to be able to bridge an NFT or FT from Flow VM to Flow EVM does the developer need to write and deploy a solidity contract on Flow EVM to match the Cadence contract of that NFT or FT?

A corresponding EVM contract must exist, but the bridge deploys it on "onboarding". This is done so that the bridge can mint in the target (non-native) VM. The bridge takes a Cadence type, assesses whether it's an NFT or FT, then calls into an EVM factory contract that deploys an ERC721/ERC20 with identifying information about the corresponding Cadence asset. The bridge then retains an association between the Cadence type and the corresponding bridge-deployed EVM contract.

Assuming an NFT was bridged from Flow VM to Flow EVM. If that token changes owners (through a solidity marketplace contract for example) what events would be triggered? Are any events triggered on the Flow VM side or only on the Flow EVM side ?

On bridging from Cadence -> EVM, the NFT is locked in bridge escrow. Fulfillment of the bridge request emits an event (in Cadence) identifying the type, id, evm ID, recipient, and ERC721 defining contract. Once in EVM, the NFT can be transferred like any ERC721, emitting all the associated ERC721 standard events in EVM. Upon bridging back, the current owner of the ERC721 token must initiate the bridge request from EVM -> Cadence as the ERC721 contract remains the source of truth on the NFT's ownership. As part of that bridge request, the ERC721 is transferred to the bridge's COA, effectively escrowing the EVM NFT, transfer is validated, and the originally escrowed Cadence NFT is unlocked and returned to the caller. A corresponding event is also emitted (in Cadence) with identifying info about the bridging request, namely type, id, EVM ID, calling COA EVM address, and defining ERC721 address.