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.
-
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
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.
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),
}
}
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.
This project is licensed under the Apache 2.0 license.
See LICENSE for more information.
This project is a collaboration between Kasar and Taproot Wizards ๐งโโ๏ธ
Antoine ๐ป |
Antiyro ๐ป |
Betacod ๐ป |
Sparqet ๐ป |
Axel Izsak ๐ป |
Zarboq ๐ป |