I used the message_time.rs code from iotaledger/iota.rs to send a message to the Chrysalis testnet:

use iota::Client;

async fn main() {
    // Create a client instance
    let iota = Client::builder()

    let message = iota

    let message_id = message.id().0;
    println!("Message ID: {}", message_id);

    let _ = iota.retry_until_included(&message_id, None, None).await.unwrap();

    let metadata = iota.get_message().metadata(&message_id).await.unwrap();
    match metadata.referenced_by_milestone_index {
        Some(ms_index) => {
            let ms = iota.get_milestone(ms_index).await.unwrap();
            println!("Message got referenced by milestone {} at {}", ms_index, ms.timestamp);
        _ => println!("Message is not referenced by a milestone"),

If the message is successfully added to the testnet the code returns the message_id, for eg.

Message ID: a9c7dc2745b0c60f379be01eacbda9e8fdf2019aebaba41710ebd5315a4ecf0c

The data associated with the ID can be viewed via Chrysalis Testnet Explorer by entering the MessageID in the search bar. An example of the data is shown in the next image.

enter image description here

I tried to write a program to get INDEX UTF8 and DATA UTF8 data from the message by using the MESSAGE ID, but I couldn't figure out from the API Documentation which function/method to use. Can please someone help?


1 Answer 1


iota.get_message().metadata(&message_id) consumes the GET /api/v1/messages/{messageID}/metadata endpoint, which does not provide the actual message contents. To get the message contents, you have to use the GET /api/v1/messages/{messageID} endpoint, provided by iota.get_message().data(&message_id). Try:

    let msg = iota.get_message().data(&message_id).await.unwrap();
    if let Payload::Indexation(payload) = msg.payload().as_ref().unwrap() {
            "Index: {}",
            String::from_utf8(payload.index().to_vec()).expect("Found invalid UTF-8")
            "Data: {}",
            String::from_utf8(payload.data().to_vec()).expect("Found invalid UTF-8")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.