Basic NFT Vault Specification
Spec
- What does this bridge do? Why did you build it?
This bridge allows users to deposit and withdraw NFTs to/from Aztec Connect.
- What protocol(s) does the bridge interact with?
ERC-721 contracts on Etheruem.
ERC-721 contracts are the most widely used NFT standard. A bridge that supports 721 contracts should be able to handle most NFTs.
-
What is the flow of the bridge?
- What actions does this bridge make possible?
- Depositing NFTs to Aztec from an Ethereum account
- Withdrawing NFTs from Aztec to an Ethereum account
- Transfering NFTs around the Aztec network, anonymously
- Are all bridge interactions synchronous, or is the a asynchronous flow?
- all interactions are synchronous
- For each interaction define:
- All input + output tokens, including AztecType info
- Deposit:
- input: ETH
- output: VIRTUAL
- Withdrawal:
- input: VIRTUAL
- output: ETH (not used, == 0)
- All relevant bridge address ids (may fill in after deployment)
- use of auxData
- gas usage
- get virtual assets: 47726 gas
- withdraw: 97744 gas
- cases that would make the interaction revert (low liquidity etc)
- Eth address to withdraw to is not registered
- Please include any diagrams that would be helpful to understand asset flow.
-
Please list any edge cases that may restrict the usefulness of the bridge or that the bridge prevents explicit.
As written, this bridge has very little functionality. We will think about how to extend this functionality in future NFT specs.
Providing privacy for NFTs is also tricky because each NFT is unique. Aztec users typically get privacy by hiding a crowd of users, but with NFTs the size of the crowd is 1.
-
How can the accounting of the bridge be impacted by interactions performed by other parties than the bridge? Example, if borrowing, how does it handle liquidations etc.
-
What functions are available in /src/client? How should they be used?
getAuxData
- should return the range of registered eth addresses for withdrawal
getExpectedOutput
- this should always return 1 output for deposits
- should always return 0 outputs for withdrawals
getInteractionPresentValue
- this should always return 1 for a VIRTUAL asset that is mapped to an NFT
- Is this contract upgradable? If so, what are the restrictions on upgradability?
No
- Does this bridge maintain state? If so, what is stored and why?
Yes. The bridge stores a few things in state
- Nft Assets
- These are structs that map an nft id (unique to the contract) to the corresponding NFT info (collection, tokenId, virtual asset id)
- Any other relevant information
NftVault.sol
Structs
Nft data is stored in a NftAsset struct
Mappings
Functions
convert
Cases:
- deposit
- Assets: (ETH in (1 wei), VIRTUAL out)
- auxData: none
- withdraw
- Assets: (VIRTUAL in, VIRTUAL (not used) out)
- auxData: withdraw address id, 64 bits?
Match Deposit
User Flow:
- Aztec account triggers a deposit
- Eth account approves this bridge to take their NFT
- Eth account calls
matchDeposit
, which takes the NFT and holds it, matching the owner to the virtual asset id