Ankr Bridge mechahics
Smart contracts involved in bridging Liquid Staking tokens are:
- Ankr Ethereum bridge — sends assets to other blockchains and receives assets sent to Ethereum.
- Ankr Polygon bridge — sends assets to other blockchains and receives assets sent to Polygon.
- Ankr Binance bridge — sends assets to other blockchains and receives assets sent to Binance.
The mechanics of what's going on under the hood when a user transfers their funds between network can be described as following:
The user has Ankr Liquid Staking tokens on the network where our smart contract minted them for said user.
The user wants to transfer them onto another network. They visit Ankr Bridge, choose the amount to be transferred and click Approve. That causes Ankr Bridge to call the
approve()function of the bridging smart contract to allow transfer of the assets. From the user side, it looks like they approve the operation in their Metamask.
The user clicks Send on the page, which causes Ankr Bridge to call the
deposit()function to transfer the assets to the destination network. This operation is called peg-in.
The user's assets are now locked on Ankr Bridge and the user gets the transaction hash.
The user sends the transaction hash to Ankr backend for notarization.
The user clicks Switch on the page and switches to the destination network.
The user clicks Receive, which causes Ankr Bridge to call the
withdraw()function (both for ERC-20 or native tokens). This operation is called peg-out.
The user sees the transferred assets deposited to their wallet on the detination network.
To sum up, the flow in any direction is the same:
approve() (if necessary) ->