This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from vianetwork/feat/inscriber-example-and-fix
feat: inscriber example
- Loading branch information
Showing
9 changed files
with
398 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use via_btc_client::types as inscribe_types; | ||
use via_btc_client::{inscriber::Inscriber, types::BitcoinNetwork, types::NodeAuth}; | ||
|
||
use anyhow::{Context, Result}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// get the node url and private key from the environment | ||
|
||
// export BITCOIN_NODE_URL="http://example.com:8332" | ||
// export BITCOIN_PRV=example_wif | ||
|
||
let url = std::env::var("BITCOIN_NODE_URL").context("BITCOIN_NODE_URL not set")?; | ||
let prv = std::env::var("BITCOIN_PRV").context("BITCOIN_PRV not set")?; | ||
|
||
let mut inscriber_instance = Inscriber::new( | ||
&url, | ||
BitcoinNetwork::Regtest, | ||
NodeAuth::UserPass("via".to_string(), "via".to_string()), | ||
&prv, | ||
None, | ||
) | ||
.await | ||
.context("Failed to create Inscriber")?; | ||
|
||
println!( | ||
"balance: {}", | ||
inscriber_instance | ||
.get_balance() | ||
.await | ||
.context("Failed to get balance")? | ||
); | ||
|
||
let l1_da_batch_ref = inscribe_types::L1BatchDAReferenceInput { | ||
l1_batch_hash: zksync_basic_types::H256([0; 32]), | ||
l1_batch_index: zksync_basic_types::L1BatchNumber(0_u32), | ||
da_identifier: "da_identifier_celestia".to_string(), | ||
blob_id: "batch_temp_blob_id".to_string(), | ||
}; | ||
|
||
let l1_batch_da_txid = inscriber_instance | ||
.inscribe(inscribe_types::InscriptionMessage::L1BatchDAReference( | ||
l1_da_batch_ref, | ||
)) | ||
.await | ||
.context("Failed to inscribe L1BatchDAReference")?; | ||
|
||
println!("---------------------------------First Inscription---------------------------------"); | ||
let context = inscriber_instance.get_context_snapshot()?; | ||
println!("context: {:?}", context); | ||
|
||
let l1_da_proof_ref = inscribe_types::ProofDAReferenceInput { | ||
l1_batch_reveal_txid: l1_batch_da_txid[1], | ||
da_identifier: "da_identifier_celestia".to_string(), | ||
blob_id: "proof_temp_blob_id".to_string(), | ||
}; | ||
|
||
let _da_proof_ref_reveal_txid = inscriber_instance | ||
.inscribe(inscribe_types::InscriptionMessage::ProofDAReference( | ||
l1_da_proof_ref, | ||
)) | ||
.await | ||
.context("Failed to inscribe ProofDAReference")?; | ||
|
||
println!( | ||
"---------------------------------Second Inscription---------------------------------" | ||
); | ||
let context = inscriber_instance.get_context_snapshot()?; | ||
|
||
println!("context: {:?}", context); | ||
|
||
println!("---------------------------------End---------------------------------"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.