How bridging FA tokens works
The process of bridging FA tokens is similar to the process of bridging tez. In short, the bridge uses tickets to send tokens from the source network to the target network.
Contracts
The bridging process relies on smart contracts that convert tokens to tickets and transfer the tickets between Tezos and Etherlink. These contracts are an implementation of the TZIP-029 standard for bridging between Tezos and Etherlink.
Each FA token needs its own copy of these contracts to be able to bridge the token:
- Ticketer contract: Stores tokens and issues tickets that represent them
- Token bridge helper contract: Accepts requests to bridge tokens on layer 1, uses the ticketer contract to get tickets for them, and sends the tickets to Etherlink
- ERC-20 proxy contract: Stores tickets and mints ERC-20 tokens that are equivalent to the FA tokens in layer 1
You can run these transactions using the bridge, as described in Bridging FA tokens between Tezos layer 1 and Etherlink. For information about how to run these transactions without using the bridge, see Sending FA bridging transactions. Examples of these contracts and tools to deploy them are available in the repository https://github.com/baking-bad/etherlink-bridge.
Depositing tokens from layer 1 to Etherlink
The process of bridging FA-compatible tokens from layer 1 to Etherlink (also known as depositing tokens) follows these general steps:
-
A Tezos user gives the token bridge helper contract access to their tokens.
- For FA1.2 tokens, the user gives the helper contract an allowance of tokens.
- For FA2 tokens, the user makes the helper contract an operator of their tokens.
For information about token access control, see Token standards on docs.tezos.com.
-
The user calls the helper contract's
deposit
entrypoint. The request includes the amount of tokens to bridge, the address of the Etherlink Smart Rollup, and the user's Etherlink wallet address, but not the tokens themselves. -
The token bridge helper contract stores the address of the Etherlink Smart Rollup and the user's Etherlink address temporarily.
-
The helper contract (as an operator of the user's tokens or with an allowance of the user's tokens) calls the token contract to transfer the tokens from the user's account to its account.
-
The helper contract calls the ticketer contract's
deposit
entrypoint and includes the tokens. -
The ticketer contract stores the tokens and creates a ticket that represents the receipt of the tokens.
-
The ticketer contract sends the ticket back to the helper contract.
-
The helper contract forwards the ticket to the Smart Rollup inbox and clears its storage for the next transfer.
-
The Etherlink Smart Rollup kernel receives the ticket and puts it and information about it (including the addresses of the proxy contract and the user's Etherlink wallet address) in the delayed inbox.
-
The sequencer reads the ticket and information about it from the delayed inbox, leaves the ticket in control of the Smart Rollup itself, and calls the null address precompiled contract (
0x000...000
) with the information. -
The null address precompile sends the information about the deposit to the FA bridging precompiled contract (
0xff0...0002
), which then emits aQueuedDeposit
event which contains thedepositId
information needed to complete the transfer. -
Any user can call the FA bridging precompiled contract's
claim
function, which causes the contract to call the ERC-20 proxy contract. For tokens supported by the bridge, an automated program calls theclaim
function for you. -
The ERC-20 proxy contract mints the equivalent tokens and sends them to the user's Etherlink account.
This diagram is an overview of the process of bridging tokens from layer 1 to Etherlink:
