forked from iotaledger/iota.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
08_data_message.rs
33 lines (26 loc) · 919 Bytes
/
08_data_message.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! cargo run --example 08_data_message --release
use iota_client::{Client, Result};
/// In this example we will send a message without a payload
#[tokio::main]
async fn main() -> Result<()> {
let iota = Client::builder()
.with_node("https://api.lb-0.testnet.chrysalis2.com")?
// .with_permanode("http://18.196.167.57:8000/api/permanode/", None, None)?
.finish()
.await?;
let message = iota
.message()
.with_index("Hello")
.with_data("Tangle".as_bytes().to_vec())
.finish()
.await?;
println!(
"Message sent https://explorer.iota.org/testnet/message/{}\n",
message.id().0
);
let fetched_message_ids = iota.get_message().index("Hello").await.unwrap();
println!("Messages with Hello index: {:?}", fetched_message_ids);
Ok(())
}