Cross-chain bridge
Unit Zero L1 network operates atop Waves L0 network serving as a beacon chain, facilitating trustless interactions and providing consensus and economic incentives. The bridge protocol implements token transfers between the L1 and L0 networks. This article outlines the operational mechanisms of transferring different types of tokens: the UNIT0 native token and other assets.
Native token transfers
L1 to L0 Transfer
The native token of the L1 network can be transferred to the L0 network by converting it into a wrapped token.
A sender in L1 invokes the Bridge Contract which locks Unit0 permanently and then emits an event.
The events are captured by the L1 consensus client.
When invoking the Chain Contract in L0 to post the block metadata, the miner also applies a cryptographic digest of L1-to-L0 transfers.
The recipient have to wait until the block becomes irreversible (~ 200 L1 epochs). This hold ensures transaction finality, preventing double spending and token loss during potential L1 reorganizations.
After that, the recipient in L0 invokes the Chain Contract, applying the cryptographic proof of the transfer.
The Chain Contract in L0 mints the wrapped Unit0 token and sends it to the recipient.
L0 to L1 transfer
Reverse transfers are much easier and almost instant.
A sender in L0 invokes the Chain Contract applying the wrapped Unit0 token.
The Chain Contract burns the wrapped token and adds a record in its state.
The miner in L1 reads the state and adds Unit0 withdrawals to the block. When posting the block metadata in L0, the miner marks the transfers as processed.
The native Unit0 token becomes available to the recipient in L1 in the next block.
Custom token transfers
Transfers of custom (non-native) tokens are handled similarly. А correspondence between the tokens in L1 and those in L0 is established by the Chain Contract. If the token is originally created in L1, the Chain Contract issues the wrapped token in L0. If the token is originally created in L0, its smart contract in L1 must emit events required to transfer the token back to L0.
Last updated