- return to IOTA Rebased Useful Links
IOTA Contract Writing Text Message
The full code for the sample MOVE contract is below. It was published to the Mainnet (2nd Nov 2025) and can be seen using the Package Id linked here: 'eternal_message' as seen on IOTA Mainnet
Calling the published contract. This is the general format with a sample message text included.
iota client call --package PACKAGE_ID --module eternal_message --function create_message --args "If Twitter became big with just 140 characters then nothing is stopping us" 0x6
This is to call the contract as published with the shown Package ID
iota client call --package 0x3c538bbe163b3641444d4465dbc502556b54b7434536c8aa1b317af97687d9fb --module eternal_message --function create_message --args "M1. If Twitter became big with just 140 characters then nothing is stopping us" 0x6
First step was to create the files. First was a Move.toml file displayed immediately below.
[package]
name = "message_board"
version = "0.0.1"
edition = "2024.beta"
[dependencies]
Iota = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/iota-framework", rev = "mainnet" }
[addresses]
message_board = "0x0"
iota = "0x0000000000000000000000000000000000000000000000000000000000000002"
Next in a 'sources' folder, the file 'message_board.move'
module message_board::eternal_message {
use std::string::{Self, String};
use iota::event;
/// The message object that will be stored on-chain
public struct Message has key, store {
id: UID,
content: String,
author: address,
timestamp: u64,
}
/// Event emitted when a new message is created
public struct MessageCreated has copy, drop {
message_id: ID,
author: address,
content: String,
timestamp: u64,
}
/// Create a new eternal message (max 140 characters)
public entry fun create_message(
content: vector,
clock: &iota::clock::Clock,
ctx: &mut TxContext
) {
let content_string = string::utf8(content);
// Enforce 140 character limit
assert!(string::length(&content_string) <= 140, 0);
let sender = ctx.sender();
let timestamp = iota::clock::timestamp_ms(clock);
let message = Message {
id: object::new(ctx),
content: content_string,
author: sender,
timestamp,
};
let message_id = object::id(&message);
// Emit event
event::emit(MessageCreated {
message_id,
author: sender,
content: content_string,
timestamp,
});
// Transfer the message object to the sender
// This makes it owned by them and permanently on-chain
transfer::public_transfer(message, sender);
}
/// Get message content (view function)
public fun get_content(message: &Message): String {
message.content
}
/// Get message author (view function)
public fun get_author(message: &Message): address {
message.author
}
/// Get message timestamp (view function)
public fun get_timestamp(message: &Message): u64 {
message.timestamp
}
}