Bridge ERC1155 through the Custom Gateway

Whenever you want to bridge an ERC1155 NFT, you may interact with the Gateway and NFT contracts on Goerli and Scroll Alpha. In this guide, we'll cover different approaches to doing so.

Step 1: Launch an 1155 Contract on Goerli

If you already have an existing token on Goerli, feel free to skip this step. If you don't have an ERC1155 on L1, you can grab the following minimal example and launch it on L1.

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract MockNFT is ERC1155 {
    constructor() ERC1155("") {
    }

    function mint(address to, uint256 id, uint256 amount) public {
        _mint(to, id, amount, "");
    }
}

Step 2: Launch the Gateway on Goerli

This step is needed only if you want to launch your own Gateway. Launching your own gateway is fully permissionless and also allows you to have custom logic called every time a token is deposited. You can skip this step if you use the Scroll ERC1155 bridge launched at 0xd1bE599aaCBC21448fD6373bbc7c1b4c7806f135. More information is available here. This contract will allow you to send ERC1155 tokens from Goerli to Scroll Alpha.

Step 3: Launch the Gateway on Scroll

This step is needed only if you want to launch your own Gateway. Launching your own gateway is fully permissionless and also allows you to have custom logic called every time a token is deposited. You can skip this step if you use the Scroll ERC1155 bridge launched at 0xfe5Fc32777646bD123564C41f711FF708Dd48360. More information is available here. This contract will allow you to send ERC1155 tokens from Goerli to Scroll Alpha.

Step 3: Launch the custom token on Scroll Alpha

This contract has to follow the IScrollERC1155 standard interface. It has to allow the gateway to mint tokens on deposit and burn on withdrawal. The following example shows a sample implementation by passing as constructor parameters the L2 gateway (either the one you just launched or Scroll's at 0xd1bE599aaCBC21448fD6373bbc7c1b4c7806f135) and your token address on Goerli.

Step 4: Initialize the Gateways

This step is only needed if you're launching your own custom Gateways. If you're using Scroll's Gateway, the Scroll team will take care of this.

On Goerli, first call the initialize function on the Goerli L1 Gateway by passing the following params:

  • counterpart : L2 gateway you just launched on Scroll Alpha.

  • messenger: The messenger contract on Goerli at 0x5260e38080BFe97e6C4925d9209eCc5f964373b6

Next, you will need to call the updateTokenMapping to bind the L1 and L2 tokens.

  • l1 token: Token launched on Goerli

  • l2 token: Token launched on Scroll Alpha

Now let's move to Scroll Alpha and call the initialize function on your Scroll Alpha L2 Gateway:

  • counterpart: L1 gateway you just launched on Goerli.

  • messenger: The messenger contract on Scroll Alpha at 0xb75d7e84517e1504C151B270255B087Fd746D34C

Finally, let's bind the tokens on Scroll Alpha by calling updateTokenMapping on the same contract:

  • l2 token : Token launched on Scroll Alpha

  • l1 Token: Token launched on Goerli

Step 5: Deposit from Goerli to Scroll Alpha

Deposits can be made by first approving the Gateway on L1 and then calling the depositERC1155 function by passing the following parameters. Notice that this is a payable function, so if you send 0.0001 ETH, it should be more than enough to confirm your transaction on L2:

  1. token: token address on Goerli

  2. token id: token id that you want to deposit

  3. amount: amount of tokens you want to deposit

  4. gas limit: 4000 should be enough

Last updated

Was this helpful?