Giter VIP home page Giter VIP logo

nft-bridge-workshop-demo's Introduction

Ethereum / Arbitrum NFT Bridge Workshop!

DISCLAIMER: For workshop / demo / testnet purposes only; has not been audited, don't use this on mainnet, etc.

Today we'll be building an ERC-721 bridge!

Arbitrum

Arbitrum is a layer 2 Optimistic Rollup chain that runs on top of Ethereum. It suppots arbitrary asynchronous contract calls:

L1 to L2:

    function createRetryableTicket(
        address to,
        uint256 l2CallValue,
        uint256 maxSubmissionCost,
        address excessFeeRefundAddress,
        address callValueRefundAddress,
        uint256 gasLimit,
        uint256 maxFeePerGas,
        bytes calldata data
    ) external payable returns (uint256);

L2 To L1:

interface ArbSys {

    function sendTxToL1(address destination, bytes calldata data)
        external
        payable
        returns (uint256);

}

We will use these arbitrary cross-chain message affordances to build our bridge; we'll be using Goerli / Arbitrum Goerli Rollup Testnet.

Minimum Viable NFT Bridge

The NFT bridge will have similar architecture to Arbitrum "Custom ERC20 Bridge."

2 "Gateway" contracts โ€“ one at L1 and one at L2 โ€” are responsible for mapping L1 ERC721s to their L2 ERC721s counterparts, and for enabling deposits and withdrawals.

Flow

  1. ERC721 is deployted on L1 with affordance to register its L2 token address to L1 gateway.
  2. ERC721 is deployed on L2 with affordance for L2 gateway to mint/burn.
  3. X chain message: L1 ERC721 registers its L2 address on L1 and L2 via retryable ticket.
  4. X chain message Deposit to L2 via retryable ticket (escrow token in L1 gateway and mint L2 token at L2).
  5. X chain message Withdraw via ArbSys/Outbox (burn token at L2 and transfer from escrow at L1.)

Setup / Commands

  1. git clone this repo

  2. yarn install

  3. Add env variables (i.e., to a .env file):

    TESTNET_PRIVKEY=xyzxyz
    GOERLI_RPC=https://goerli.infura.io/v3/infura_key
    
  4. Complete function bodies in contracts (i.e., do all the "// DO!" things)

  5. Deploy contracts:

    yarn hardhat deploy-all
    ```bash
  6. Test out a register / deposit:

    yarn hardhat register-and-deposit
    

nft-bridge-workshop-demo's People

Contributors

dzgoldman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.