-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffc6619
commit acad145
Showing
3 changed files
with
43 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use avail_rust::{avail, error::ClientError, Nonce::BestBlockAndTxPool, Options, SDK}; | ||
|
||
type DataSubmissionCall = avail::data_availability::calls::types::SubmitData; | ||
|
||
pub async fn run() -> Result<(), ClientError> { | ||
let sdk = SDK::new("wss://rpc-hex-devnet.avail.tools/ws").await?; | ||
let online_client = &sdk.online_client; | ||
|
||
let account = SDK::charlie()?; | ||
let data = String::from("My Data").into_bytes(); | ||
let options = Some(Options::new().nonce(BestBlockAndTxPool).app_id(1)); | ||
let tx = sdk.tx.data_availability.submit_data(data); | ||
let mut si = 0; | ||
let mut ei = 0; | ||
|
||
// Data Submission | ||
loop { | ||
println!("Preparing new Tx execution."); | ||
let res = tx.execute_wait_for_inclusion(&account, options).await?; | ||
if let Some(call_data) = res.get_data::<DataSubmissionCall>(online_client).await { | ||
si += 1 | ||
} else { | ||
println!("Something went wrong :O"); | ||
ei += 1 | ||
} | ||
|
||
println!( | ||
"Tx Success. Block Number: {}. Number of success: {}, Number of Errors: {}", | ||
res.block_number, si, ei | ||
); | ||
} | ||
} |
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