Coder Social home page Coder Social logo

bitcoin-da's Introduction

๐Ÿง™โ€โ™‚๏ธ Bitcoin-da-rs

This crate allows to use bitcoin as a data availability layer.

It offers both write and read functions. This can be incorporated into any sequencer written in Rust and has been specifically designed for Madara.

This repo is rust adaptation of rollkit's bitcoin-da.

The code isn't production ready. It is highly experimental.

Prerequisites

  • Install bitcoind & bitcoin-cli

  • Launch a Bitcoin daemon

To launch a bitcoin daemon, run the following command:

bitcoind -conf=path_to/bitcoin.conf

If you don't already have a wallet, create one by doing:

bitcoin-cli createwallet test

Then mine some blocks:

bitcoin-cli -regtest -generate 150

Building

The library can be built and tested using cargo:

git clone [email protected]:KasarLabs/da.git
cd da
cargo build

Please refer to the cargo documentation for more detailed instructions.

Example

fn test_write() {
        let embedded_data = b"Hello, world!";
        let relayer = Relayer::new(&Config::new(
            "localhost:8332".to_owned(),
            "rpcuser".to_owned(),
            "rpcpass".to_owned(),
        ))
        .unwrap();
        // get network, should be regtest
        let blockchain_info = relayer.client.get_blockchain_info().unwrap();
        let network_name = &blockchain_info.chain;
        let network = Network::from_core_arg(network_name)
            .map_err(|_| BitcoinError::InvalidNetwork)
            .unwrap();
        match relayer.write(&embedded_data) {
            Ok(txid) => {
                println!("Txid: {}", txid);
                println!("Successful write");
            }
            Err(e) => panic!("Write failed with error: {:?}", e),
        }
    }

Tests

You can run tests with:

cargo test

Before running the test, you must have a bitcoin node running either on regtest or signet. Then you need to change the rpc url accordingly. You also need to comment/uncomment the required network in each test function.

License

This project is licensed under the Apache 2.0 license.

See LICENSE for more information.

Contributors โœจ

This project is a collaboration between Kasar and Taproot Wizards ๐Ÿง™โ€โ™‚๏ธ

Antoine
Antoine

๐Ÿ’ป
Antiyro
Antiyro

๐Ÿ’ป
Betacod
Betacod

๐Ÿ’ป
Sparqet
Sparqet

๐Ÿ’ป
Axel Izsak
Axel Izsak

๐Ÿ’ป
Zarboq
Zarboq

๐Ÿ’ป

bitcoin-da's People

Contributors

0xeniotna avatar antiyro avatar sparqet avatar eytanlvy avatar zarboq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.