Layer 1 blockchains are safe and resilient to failures but have a low transaction per second (TPS) count and can suffer during activity peaks.
Layer 2 solutions such as sidechains can help to resolve these problems. A sidechain is a secondary blockchain that is paired to a parent blockchain and is able to communicate with it. A sidechain works like any blockchain and has the same core properties, with the added feature that its consensus is witnessed by the main chain.
A bridge is needed between the layer 1 and the layer 2 to ensure that tokens are safely mirrored on both sides.
At Marigold, we develop a sidechain solution and a native Tezos bridge:
- Deku-Canonical (Deku-C): a Tezos sidechain implementation;
- TzPortal: a multi-asset and multi-layer 2 bridge for Tezos. The bridge currently supports Deku as well as experimental layer 2 solutions like Chusai and TORU.
You will have to send assets from layer 1 to layer 2. Deku supports Tezos tickets so you can swap your L1 tokens against tickets to be sent to the L2.
You can either run your own Deku-C or use an existing instance on Jakartanet. We recently released an alphanet version of Deku on Jakartanet, which you can already freely use.
We will now demonstrate TzPortal and Deku-C alphanet on Jakartanet. As Deku-C is still not supported by any mainstream wallet, you will have to use the command-line client to interact with the chain.
- First, you need an account/wallet for Jakartanet. Follow this link to install Temple wallet). ~It will create your first account~ Follow the instructions in Temple to create your account.
- Get some free Tez from the Marigold Faucet (video tutorial); don’t forget to select Jakartanet network.
- You can set the address of TzPortal smart contract on your local shell for later commands:
- You will have to install nix and clone the deku-c repository
1. Connect to TzPortal
Go to TzPortal (Jakarta) website https://jakartanet.tzportal.marigold.dev/
Click on Connect button to login with your account on Temple wallet.
2. Deposit some assets on Deku
Click on the Deposit Menu on top
In the following picture, we are connected with the tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb account (aliased as alice in tezos-client), and we list its assets on the left-side panel.
Now, we need to create a L2 address on Deku side. To generate a new account on Deku with the deku-cli, use
Do this twice and you get 2 output files with the following form:
Let's send 0.00001 tz to our first account (tz1QuW9jPNiiVZ1zEmNCh6jK81934xp5C23U)
On the right panel, the Deku contract, you can se the global vault updated with +10 mutez represented by 10 XTZ tickets.
To know the balance of tz1QuW9jPNiiVZ1zEmNCh6jK81934xp5C23U, you also need to use the deku-cli:
Your balance should have increased by +10 XTZ tickets.
3. Do a layer 2 transfer
4. Withdraw your tickets
Last step, you want tz1XA2v9rgwheKay4TF3c3bzrpQgoQsd4rdC to withdraw 1 ticket and get back the corresponding 1 mutez to alice:
The deku-cli prints out an operation hash, which you will need again later. Store the operation hash in a variable, e.g.
Withdrawal from the layer 2 works in several steps: after sending a withdraw transaction to Deku, you need to ask for a proof that the withdrawal was executed, which you will give back to TzPortal. Ask for the proof now:
Now you have a proof, keep it and go to TzPortal Withdraw menu !
Enter the same quantity, token type, proof id (below as note 1), proof hash (as note 2) and eventually the proof list (as note 3):
Click on Withdraw button and wait for confirmation.
Network node synchronization
If you have this kind of error :
Just retry to send the transaction a few times until it passes. It means that the Tezos node you are pointing too is a bit behind the last block sync.
Vault quantity not refreshing
For FA1.2 and FA2, there is a batch that runs every 15s to pull all pending deposits/withdraw and execute the transactions. It means it is not sync with your browser. Just wait maximum 15s and refresh the page to see last vault quantity.
Bad Deku proof
If you get this error during a withdraw:
It means that the proof you entered is wrong. Check again if you have the correct ticket token type, ticket quantity, proof id, proof hash and the list in right order of the proofs.
The issue comes from wrong ticket quantity.
There is a difference between token quantity and ticket quantity, because of the number of decimals. Be sure to multiply the token quantity by it's number of decimals to get the ticket quantity.
You are too fast between the withdraw-proof generation and the TzPortal withdraw button
It takes time for Deku to sync the withdraw from L2 to L1, just retry every 15s to not see the error message as invalid in Temple. It should take less than 30 seconds to synchronize.
TzPortal V2 is currently under development. It will remove any cumbersome command lines and provide better UX like you can have on Ethereum bridges (Arbitrum, Optimism, StarkGate, ...)