How bridging FA tokens works
The bridge uses tickets to send tokens from the source network to the target network.
Bridge contracts
Three types of contracts work together to bridge FA tokens between Tezos layer 1 and Etherlink EVM:
- Ticketer contract: Stores tokens and issues tickets that represent them.
- Token bridge helper contract: Handles bridging requests on layer 1 and coordinates ticket transfers.
- ERC-20 proxy contract: Stores tickets and mints ERC-20 tokens that are equivalent to the FA tokens in layer 1.
These contracts implement the TZIP-029 standard for token bridging.
Depositing FA tokens from layer 1 to Etherlink EVM
To deposit FA tokens, users first grant access to their tokens (an allowance for FA1.2 tokens or operator status for FA2 tokens). Then they call the deposit entrypoint on the token bridge helper contract.
The deposit process works like this:
- The user grants the token bridge helper contract access to their tokens.
- The user calls the token bridge helper contract's
depositentrypoint. - The token bridge helper contract transfers the tokens to the ticketer contract.
- The ticketer contract issues a ticket that represents the tokens.
- The token bridge helper contract sends the ticket to the Etherlink Smart Rollup.
- The Etherlink kernel processes the ticket and makes the tokens available on Etherlink EVM.
- An automated system calls the ERC-20 proxy contract's
claimfunction, which mints equivalent ERC-20 tokens in the user's Etherlink EVM account.
Withdrawing FA tokens from Etherlink EVM to layer 1
To withdraw FA tokens from Etherlink EVM back to layer 1:
- The user calls the FA bridging precompiled contract with the details of the withdrawal, including the target layer 1 address.
- The proxy contract sends the information about the withdrawal to the helper contract by putting it in a transaction in the Smart Rollup outbox.
- After the commitment is cemented on layer 1, anyone can execute the outbox transaction.
- The helper contract receives the ticket from the outbox transaction.
- The helper contract calls the ticketer contract to burn the ticket.
- The ticketer contract transfers the original tokens to the specified layer 1 address.
Both processes rely on an implementation accessible at https://github.com/baking-bad/etherlink-bridge.