{"id":15044207,"url":"https://github.com/arealayer/demo-sidechain","last_synced_at":"2025-07-30T07:36:07.439Z","repository":{"id":257228448,"uuid":"857481286","full_name":"AreaLayer/demo-sidechain","owner":"AreaLayer","description":"Bitcoin-anchored sidechain written in Rust, leveraging Bitcoin's Proof-of-Work (PoW)","archived":false,"fork":false,"pushed_at":"2024-10-03T11:10:10.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-30T23:41:21.440Z","etag":null,"topics":["bitcoin","lightning-network","merge-mining","proof-of-work","sidechain"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AreaLayer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-14T19:16:13.000Z","updated_at":"2024-10-03T11:10:13.000Z","dependencies_parsed_at":"2024-09-15T12:30:46.866Z","dependency_job_id":"458ba3ce-9405-4f43-9e3b-86d1c8de4ac7","html_url":"https://github.com/AreaLayer/demo-sidechain","commit_stats":null,"previous_names":["arealayer/demo-sidechain"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreaLayer%2Fdemo-sidechain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreaLayer%2Fdemo-sidechain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreaLayer%2Fdemo-sidechain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreaLayer%2Fdemo-sidechain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AreaLayer","download_url":"https://codeload.github.com/AreaLayer/demo-sidechain/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237915423,"owners_count":19386724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","lightning-network","merge-mining","proof-of-work","sidechain"],"created_at":"2024-09-24T20:50:12.787Z","updated_at":"2025-02-09T06:31:52.289Z","avatar_url":"https://github.com/AreaLayer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Rust Bitcoin Sidechain**⚡\n\nThis project implements a **Bitcoin-anchored sidechain** written in Rust, leveraging Bitcoin's **Proof-of-Work (PoW)** consensus mechanism through **merge mining**. The sidechain is fully anchored to Bitcoin Core, but without a two-way peg for asset transfer. Instead, it inherits the security of Bitcoin through periodic anchoring and merge mining.\n\nIdea inspired by RSK and redesing by Rsync\n\nDeveloped by 22388o\n\n## **Overview**\n\nThis sidechain is designed to:\n- **Use Bitcoin's PoW consensus**: No separate consensus mechanism is implemented. The sidechain inherits Bitcoin's consensus via merge mining.\n- **Be anchored to Bitcoin**: Sidechain blocks are periodically anchored in Bitcoin by including sidechain block headers in Bitcoin transactions.\n- **Merge-mining compatibility**: Bitcoin miners can mine blocks on both Bitcoin and the sidechain simultaneously without needing to allocate additional resources.\n\n## **Features**\n- **Merge Mining (Auxiliary Proof-of-Work)**: The sidechain allows miners to mine Bitcoin and the sidechain simultaneously by reusing Bitcoin's PoW.\n- **Bitcoin-anchored security**: Sidechain blocks are periodically anchored in Bitcoin blocks for additional security and tamper-proofing.\n- **Rust implementation**: The sidechain is built using Rust, leveraging the `rust-bitcoin` crate for interaction with the Bitcoin protocol.\n- **No asset peg**: The sidechain is non-peg, meaning there is no two-way transfer of assets between Bitcoin and the sidechain.\n- **No soft fork**: The sidechain works without need soft forks and is compatible with them when happen some soft fork in the future\n\n## **Components**\n1. **Sidechain Block Structure**: The sidechain block is similar to a Bitcoin block but contains a reference to a Bitcoin block hash via the merge mining (AuxPoW) mechanism.\n2. **AuxPoW (Auxiliary Proof-of-Work)**: This mechanism allows the sidechain to share Bitcoin's PoW. Miners submit a valid Bitcoin block and a sidechain block together.\n3. **Anchoring Mechanism**: Periodically, sidechain block headers are committed to the Bitcoin blockchain using an OP_RETURN transaction, which acts as a checkpoint.\n\n## **Architecture**\n\n- **Bitcoin Core Integration**: The sidechain communicates with Bitcoin Core via the JSON-RPC API to retrieve Bitcoin block headers and submit anchor transactions.\n- **Merge Mining**: Miners mine both Bitcoin and sidechain blocks using a single PoW computation.\n- **Validation**: Sidechain nodes validate blocks based on Bitcoin’s PoW and ensure that the sidechain block is correctly linked to a valid Bitcoin block.\n\n## **How It Works**\n1. **Mining**: Bitcoin miners participate in mining both Bitcoin and sidechain blocks. The sidechain block contains the hash of a Bitcoin block, and the same PoW solution is used for both.\n2. **Anchoring**: Periodically, the sidechain state is anchored in Bitcoin by committing block headers using an OP_RETURN transaction.\n3. **Consensus**: The sidechain leverages Bitcoin’s consensus by reusing Bitcoin’s PoW via the AuxPoW mechanism. No new consensus mechanism is required.\n\n## **Setup and Installation**\n\n### **Prerequisites**\n- **Rust**: Ensure Rust is installed on your machine. You can install Rust [here](https://www.rust-lang.org/tools/install).\n- **Bitcoin Core**: Install and run Bitcoin Core (preferably in regtest mode for development).\n\n### **Steps to Run the Sidechain**\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/AreaLayer/demo-sidechain.git\n   cd sidechain\n   ```\n\n2. **Install dependencies**:\n   The project uses the `rust-bitcoin` crate. Ensure you have the necessary Rust dependencies installed:\n   ```bash\n   cargo build\n   ```\n\n3. **Run Bitcoin Core in Regtest mode**:\n   ```bash\n   bitcoind -regtest -daemon\n   ```\n\n4. **Start the sidechain**:\n   Run the sidechain node:\n   ```bash\n   cargo run --release\n   ```\n\n5. **Start merge-mining**:\n   Set up your miner to perform merge mining on both Bitcoin and the sidechain.\n\n### **Interacting with the Sidechain**\n- **Check sidechain blocks**: The sidechain node validates new blocks mined via merge mining.\n- **Submit anchors**: Anchor sidechain blocks periodically in Bitcoin using the OP_RETURN mechanism.\n\n## **Development**\n\n### **Modifying the Code**\n- The sidechain block structure and the AuxPoW (merge mining) mechanism are located in the `src/block.rs` and `src/main.rs` files, respectively.\n- The anchoring mechanism is implemented in `src/main.rs`, which includes the logic for committing sidechain headers to Bitcoin.\n\n### **Testing**\nTo test the sidechain in regtest mode:\n- Use Bitcoin Core in regtest mode for quick block generation.\n- Simulate mining on both the Bitcoin main chain and the sidechain.\n- Verify that the sidechain blocks are anchored correctly in Bitcoin blocks.\n\n## **Contributing**\nContributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.\n\n## **License**\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n## **Acknowledgments**\n- **Bitcoin Core**: This project heavily relies on Bitcoin Core for anchoring and security.\n- **rust-bitcoin**: The Rust library for Bitcoin protocol support.\n\n\n## Futures development\n\n- Compatible with BitVM\n- Others Opcodes (OP_CHECKSIG, OP_CLTV , OP_CSV, OP_IF / OP_ELSE, OP_CHECKTEMPLATEVERIFY)\n- Timelock with Lightning Network\n- Scriptless\n- Taproot\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farealayer%2Fdemo-sidechain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farealayer%2Fdemo-sidechain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farealayer%2Fdemo-sidechain/lists"}