Developer Guide
Welcome to the BeL2 ecosystem. We're excited to have you on board. This guide will walk you through the key components of BeL2 and how you can start building with our tech.
BeL2 Infrastructure
Let's break down the main services that make up BeL2:
Core Technology
The Cairo Circuit handles BTC transaction proof generation and verification. You can find it at BTCVerifier.
Next up is the EVM ZKP Contract. This smart contract verifies BTC transactions on the EVM side and stores verified transactions for other contracts to use. Check it out here: zkproof-demo-contracts.
We've also got the ZKP BTC Transaction Verifier. It's an EVM contract that makes it easier for dApps to verify BTC transactions. It's built on top of the core ZKP contract. Take a look: BtcTxVerifier.
Demo Applications
We've built some demo apps to show you what's possible with BeL2:
The Loan Demo is a React app that shows how USDT lending works with BTC as collateral. You can see it in action at lending.bel2.org. If you want to peek under the hood, the frontend code is at bel2-loan-front, and the smart contract is at Loan_Contract.
We used to have a Swap Demo, but it's been deprecated and is no longer supported. While you shouldn't use it in production, the code might still be interesting to look at. The frontend was a React app showing trustless EVM token swaps against BTC using BeL2's ZKP services. The code is still available at bel2-swap-front. The associated smart contracts are at AssetExchange and TokenExchange.
There's also an Exchange Automation Service. This service monitored BTC payments for swap orders and automatically submitted payment proofs to the ZKP contracts. It was a convenience feature so swap users didn't have to manually submit proofs. You can find the code at bel2-exchange-automations.
Getting Started
First things first, start exploring our GitHub repositories. The demo apps are a great place to begin – they'll give you a feel for how everything fits together.
Make sure you've got a solid Ethereum development setup. If you're comfortable with building on EVM chains, you're already halfway there.
Try out our loan demo. It's live, so you can see BeL2 in action without writing a line of code.
Once you're familiar with how the demo works, start poking around in the code. The frontend repository is a good starting point.
As you get more comfortable, dive into the core technology. The Cairo Circuit and EVM ZKP Contract are key to understanding how BeL2 bridges Bitcoin and EVM chains.
Best Practices for BeL2 Integration
When integrating BeL2 into your dApp, keep these best practices in mind:
-
BeL2 operations involve cross-chain interactions, which can take time. Design your dApp to handle these operations asynchronously to provide a smooth user experience.
-
Always verify BTC transactions using the ZKP BTC Transaction Verifier before taking any action in your smart contracts. Never trust unverified data.
-
BeL2 operations can be gas-intensive. Optimize your contracts to minimize gas costs, and consider implementing gas price oracles for dynamic gas pricing.
Need Help?
Building dApps can be tricky, but we've got your back. If you run into issues or have questions:
- Check out our GitHub repositories for detailed READMEs and code documentation.
- Join our developer community on Telegram to chat with other BeL2 developers.
- If you find bugs or have feature requests, please open an issue in the relevant GitHub repository.
Remember, we're all here to push the boundaries of what's possible with Bitcoin and EVM chains. Don't hesitate to experiment and think outside the box. Happy coding!
For more detailed information and advanced usage, refer to our SDK documentation.
Remember, while this quick start guide can get you up and running quickly, we strongly recommend thoroughly understanding the BeL2 ecosystem and its security implications before deploying to production.