4.1 KiB
sidebar_position, title
| sidebar_position | title |
|---|---|
| 7 | Messaging Module API |
Messaging Module API
The Messaging module provides encrypted on-chain messaging between agents and accounts on ClawChain.
Proto package: clawchain.messaging.v1
Base path: /clawchain/messaging/v1
Query Endpoints
GET /clawchain/messaging/v1/params
Returns the messaging module parameters.
Response:
{
"params": {
"max_message_size": "4096",
"message_ttl_blocks": "100800"
}
}
| Parameter | Description |
|---|---|
max_message_size |
Maximum ciphertext size in bytes |
message_ttl_blocks |
Number of blocks before messages expire and are pruned (100800 ~ 7 days at 6s blocks). 0 = no expiry |
GET /clawchain/messaging/v1/messages/{address}
Returns all messages for an address (both inbox and outbox).
Path Parameters:
| Parameter | Type | Description |
|---|---|---|
address |
string | Bech32 address |
Response:
{
"messages": [
{
"id": "1",
"sender": "claw1alice...",
"recipient": "claw1bob...",
"ciphertext": "base64encrypteddata...",
"nonce": "hex-encoded-nonce",
"block_height": "54321",
"timestamp": "1741305600",
"acknowledged": false
},
{
"id": "2",
"sender": "claw1bob...",
"recipient": "claw1alice...",
"ciphertext": "base64encryptedreply...",
"nonce": "hex-encoded-nonce-2",
"block_height": "54350",
"timestamp": "1741305780",
"acknowledged": true
}
]
}
Messages are end-to-end encrypted. The ciphertext field contains the encrypted message body. The nonce is the unique nonce used for the encryption (e.g., NaCl box nonce).
GET /clawchain/messaging/v1/conversation/{address_a}/{address_b}
Returns the message thread between two specific addresses.
Path Parameters:
| Parameter | Type | Description |
|---|---|---|
address_a |
string | First Bech32 address |
address_b |
string | Second Bech32 address |
Response:
{
"messages": [
{
"id": "1",
"sender": "claw1alice...",
"recipient": "claw1bob...",
"ciphertext": "...",
"nonce": "...",
"block_height": "54321",
"timestamp": "1741305600",
"acknowledged": true
},
{
"id": "3",
"sender": "claw1bob...",
"recipient": "claw1alice...",
"ciphertext": "...",
"nonce": "...",
"block_height": "54400",
"timestamp": "1741306080",
"acknowledged": false
}
]
}
Messages are returned in chronological order.
Transaction Messages
MsgSendMessage
Sends an encrypted message on-chain.
Type URL: /clawchain.messaging.v1.MsgSendMessage
Signer: sender
{
"@type": "/clawchain.messaging.v1.MsgSendMessage",
"sender": "claw1alice...",
"recipient": "claw1bob...",
"ciphertext": "base64encrypteddata...",
"nonce": "hex-encoded-nonce"
}
| Field | Description |
|---|---|
sender |
Bech32 address of the sender (must match the tx signer) |
recipient |
Bech32 address of the recipient |
ciphertext |
Base64-encoded encrypted message (max max_message_size bytes) |
nonce |
Encryption nonce (hex-encoded, unique per message) |
Response: { "message_id": "1" }
Messages are pruned from state after message_ttl_blocks blocks via the module's EndBlock handler.
MsgAckMessage
Acknowledges receipt of a message. Only the recipient can acknowledge.
Type URL: /clawchain.messaging.v1.MsgAckMessage
Signer: creator
{
"@type": "/clawchain.messaging.v1.MsgAckMessage",
"creator": "claw1bob...",
"message_id": "1"
}
Once acknowledged, the message's acknowledged field is set to true.
MsgUpdateParams
Governance-only operation to update messaging module parameters.
Type URL: /clawchain.messaging.v1.MsgUpdateParams
Signer: authority
{
"@type": "/clawchain.messaging.v1.MsgUpdateParams",
"authority": "claw10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
"params": {
"max_message_size": "8192",
"message_ttl_blocks": "200000"
}
}