Bridge an ERC721 NFT through a Custom Gateway
Scroll Alpha Testnet is now deprecated.
Please visit our new documentation for the Scroll Sepolia Testnet at https://docs.scroll.io/
Whenever you want to bridge an ERC721 NFT, you may interact with the Gateway and NFT contracts on Goerli and Scroll Alpha. In this guide, we'll cover different ways of doing so.
Step 1: Launch an NFT on Goerli
If you already have an existing token on Goerli, feel free to skip this step. If you don't have an NFT on L1, you can grab the following minimal example of an ERC721 and launch it on L1.
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 ERC721 bridge launched at 0x1C441Dfc5C2eD7A2AA8636748A664E59CB029157.
More information is available here. This contract will allow you to send NFTs from Goerli to Scroll Alpha.
Step 3: Launch the Gateway on Scroll Alpha
You can also skip this step if you use the Scroll ERC721 Gateway launched at 0x8Fee20e0C0Ef16f2898a8073531a857D11b9C700
. This contract lets you bridge tokens from Scroll Alpha back to Goerli.
Step 4: Launch the custom token on Scroll Alpha
This contract has to follow the IScrollERC721 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 0x1C441Dfc5C2eD7A2AA8636748A664E59CB029157
) and your token address on Goerli.
Step 5: 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 Goerlil2 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 at0xb75d7e84517e1504C151B270255B087Fd746D34C
Finally, let's bind the tokens on Scroll Alpha by calling updateTokenMapping
on the same contract:
l2 token
: Token launched on Scroll Alphal1 Token
: Token launched on Goerli
Step 6: Deposit from Goerli to Scroll
Deposits can be made by first approving the Gateway on L1 and then calling the depositERC721
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:
token
: token address on Goerlitoken id
: token id that you want to depositgas limit
: 4000 should be enough
After confirming first on L1 and then waiting around 20mins for your confirmation on L2, you should be able to see your NFT on any block explorer.
Last updated
Was this helpful?