So you are a depositor who wants to transfer some asset from mainnet to polygon
- You submit tokens into a bucket contract on mainnet L1 ethereum. You do this before some threshold has been met, basically a deadline for making it into one round of the bucket.
- An off-chain Relay acts like a train conductor. He's monitoring the L1 contract for those deposit events.
- This off-chain Relay then records those events in a database.
- Once the countdown to the deadline is complete, and that reserve amount is reached, the off-chain relay generates a MerkleTree root hash using all the deposits for the current bucket. Basically a receipt of all the txns in the bucket.
- The relay then initiates a transfer to Polygon by calling the L1 eth bucket contract.
- The L1 bucket transfers funds to polygon on behalf of the L2 bucket address.
- The Polygon plasma bridge confirms the transfer after some wait period.
- You can now use the relay's API to generate a proof that the deposit happened. If you were really into it, you could even generate your own proof using all the deposit events and build your own merkletree.
- Using that proof, you can withdraw the funds from the L2 bucket.
Within the hackathon, we managed to
-
build an off-chain relay
-
model out a database
-
deploy early contracts to L1 testnet (Goerli) and L2 Polygon
-
dynamically generate merkletrees (which was tough)
-
create a UI that follows the Bucketly flow
We used hardhat for testing, we used Web3 react for the frontend, used NodeJs for the relay development, Solidity for contracts.