Skip to main content

Smart Contract Reference

Complete reference for the Net Protocol smart contract. All function signatures, events, and errors are taken directly from the source code.

Contract Information​

Contract Name: Net
Contract Address: 0x00000000B24D62781dB359b07880a105cD0b64e6
Interface: INet.sol
Source: /protocol/src/net/Net.sol
Deployment: Same address across all supported chains

Supported Chains​

  • Base (Chain ID: 8453)
  • Hyperliquid EVM
  • Ink Chain
  • Ham Chain
  • Plasma Chain
  • Unichain
  • Degen Chain

Message Structure​

struct Message {
address app; // Contract address that sent the message
address sender; // User address who sent the message
uint256 timestamp; // Block timestamp when message was sent
bytes data; // Binary data payload
string text; // Human-readable text content
string topic; // Message topic/category for indexing
}

Core Functions​

Message Sending​

sendMessage​

Send a direct message to the Net protocol.

function sendMessage(
string calldata text,
string calldata topic,
bytes calldata data
) external

Parameters:

  • text: Human-readable message content
  • topic: Message category for indexing
  • data: Binary data payload

Events: Emits MessageSent(address indexed sender, string indexed topic, uint256 messageIndex)

Source: Lines 108-164 in Net.sol

sendMessageViaApp​

Send a message through an application contract.

function sendMessageViaApp(
address sender,
string calldata text,
string calldata topic,
bytes calldata data
) external

Parameters:

  • sender: User address (controlled by calling app)
  • text: Human-readable message content
  • topic: Message category for indexing
  • data: Binary data payload

Events: Emits MessageSentViaApp(address indexed app, address indexed sender, string indexed topic, uint256 messageIndex)

Source: Lines 37-102 in Net.sol

Message Retrieval​

Single Message Functions​

getMessage​

Get a single message by global index.

function getMessage(uint256 idx) external view returns (Message memory)

Parameters:

  • idx: Message index in the global message array

Returns: Message struct

Source: Lines 286-288 in Net.sol

getMessageForApp​

Get a single message from a specific application.

function getMessageForApp(uint256 idx, address app) external view returns (Message memory)

Parameters:

  • idx: Message index in the app's message list
  • app: Application contract address

Returns: Message struct from the app

Source: Lines 294-302 in Net.sol

getMessageForAppUser​

Get a single message from a specific user in a specific app.

function getMessageForAppUser(uint256 idx, address app, address user) external view returns (Message memory)

Parameters:

  • idx: Message index in the user's message list
  • app: Application contract address
  • user: User address

Returns: Message struct from the user in the app

Source: Lines 309-320 in Net.sol

getMessageForAppTopic​

Get a single message with a specific topic from an app.

function getMessageForAppTopic(uint256 idx, address app, string calldata topic) external view returns (Message memory)

Parameters:

  • idx: Message index in the topic's message list
  • app: Application contract address
  • topic: Message topic to filter by

Returns: Message struct with the specified topic

Source: Lines 327-340 in Net.sol

getMessageForAppUserTopic​

Get a single message from a specific user with a specific topic in an app.

function getMessageForAppUserTopic(uint256 idx, address app, address user, string calldata topic) external view returns (Message memory)

Parameters:

  • idx: Message index in the user's topic message list
  • app: Application contract address
  • user: User address
  • topic: Message topic to filter by

Returns: Message struct from the user with the topic

Source: Lines 348-367 in Net.sol

Batch Message Functions​

getMessagesInRange​

Get multiple messages by global index range.

function getMessagesInRange(uint256 startIdx, uint256 endIdx) external view returns (Message[] memory)

Parameters:

  • startIdx: Starting message index (inclusive)
  • endIdx: Ending message index (exclusive)

Returns: Array of Message structs

Source: Lines 375-402 in Net.sol

getMessagesInRangeForApp​

Get multiple messages from a specific application.

function getMessagesInRangeForApp(uint256 startIdx, uint256 endIdx, address app) external view returns (Message[] memory)

Parameters:

  • startIdx: Starting index in app's message list
  • endIdx: Ending index in app's message list
  • app: Application contract address

Returns: Array of Message structs from the app

Source: Lines 444-455 in Net.sol

getMessagesInRangeForAppUser​

Get multiple messages from a specific user in a specific app.

function getMessagesInRangeForAppUser(uint256 startIdx, uint256 endIdx, address app, address user) external view returns (Message[] memory)

Parameters:

  • startIdx: Starting index in user's message list
  • endIdx: Ending index in user's message list
  • app: Application contract address
  • user: User address

Returns: Array of Message structs from the user in the app

Source: Lines 463-475 in Net.sol

getMessagesInRangeForAppTopic​

Get multiple messages with a specific topic from an app.

function getMessagesInRangeForAppTopic(uint256 startIdx, uint256 endIdx, address app, string calldata topic) external view returns (Message[] memory)

Parameters:

  • startIdx: Starting index in topic's message list
  • endIdx: Ending index in topic's message list
  • app: Application contract address
  • topic: Message topic to filter by

Returns: Array of Message structs with the specified topic

Source: Lines 483-495 in Net.sol

getMessagesInRangeForAppUserTopic​

Get multiple messages from a specific user with a specific topic in an app.

function getMessagesInRangeForAppUserTopic(uint256 startIdx, uint256 endIdx, address app, address user, string calldata topic) external view returns (Message[] memory)

Parameters:

  • startIdx: Starting index in user's topic message list
  • endIdx: Ending index in user's topic message list
  • app: Application contract address
  • user: User address
  • topic: Message topic to filter by

Returns: Array of Message structs from the user with the topic

Source: Lines 504-524 in Net.sol

Count Functions​

getTotalMessagesCount​

Get the total number of messages in the system.

function getTotalMessagesCount() external view returns (uint256)

Returns: Total message count

Source: Lines 532-534 in Net.sol

getTotalMessagesForAppCount​

Get the total number of messages from a specific app.

function getTotalMessagesForAppCount(address app) external view returns (uint256)

Parameters:

  • app: Application contract address

Returns: Total message count from the app

Source: Lines 548-552 in Net.sol

getTotalMessagesForAppUserCount​

Get the total number of messages from a specific user in an app.

function getTotalMessagesForAppUserCount(address app, address user) external view returns (uint256)

Parameters:

  • app: Application contract address
  • user: User address

Returns: Total message count from the user in the app

Source: Lines 558-566 in Net.sol

getTotalMessagesForAppTopicCount​

Get the total number of messages with a specific topic from an app.

function getTotalMessagesForAppTopicCount(address app, string calldata topic) external view returns (uint256)

Parameters:

  • app: Application contract address
  • topic: Message topic to filter by

Returns: Total message count with the specified topic

Source: Lines 572-580 in Net.sol

getTotalMessagesForAppUserTopicCount​

Get the total number of messages from a specific user with a specific topic in an app.

function getTotalMessagesForAppUserTopicCount(address app, address user, string calldata topic) external view returns (uint256)

Parameters:

  • app: Application contract address
  • user: User address
  • topic: Message topic to filter by

Returns: Total message count from the user with the topic

Source: Lines 587-603 in Net.sol

Events​

MessageSent​

Emitted when a direct message is sent.

event MessageSent(address indexed sender, string indexed topic, uint256 messageIndex);

Parameters:

  • sender: Address that sent the message
  • topic: Message topic
  • messageIndex: Index of the message in the global array

Source: Lines 10-14 in EventsAndErrors.sol

MessageSentViaApp​

Emitted when a message is sent through an application.

event MessageSentViaApp(address indexed app, address indexed sender, string indexed topic, uint256 messageIndex);

Parameters:

  • app: Application contract address
  • sender: User address that sent the message
  • topic: Message topic
  • messageIndex: Index of the message in the global array

Source: Lines 16-21 in EventsAndErrors.sol

Errors​

MsgEmpty​

Reverted when attempting to send an empty message.

error MsgEmpty();

Source: Line 5 in EventsAndErrors.sol

InvalidRange​

Reverted when start index is greater than or equal to end index.

error InvalidRange();

Source: Line 6 in EventsAndErrors.sol

InvalidStartIndex​

Reverted when start index is out of bounds.

error InvalidStartIndex();

Source: Line 7 in EventsAndErrors.sol

InvalidEndIndex​

Reverted when end index is out of bounds.

error InvalidEndIndex();

Source: Line 8 in EventsAndErrors.sol

Contract Addresses​

ChainNet Contract Address
Base0x00000000B24D62781dB359b07880a105cD0b64e6
Hyperliquid EVM0x00000000B24D62781dB359b07880a105cD0b64e6
Ink Chain0x00000000B24D62781dB359b07880a105cD0b64e6
Ham Chain0x00000000B24D62781dB359b07880a105cD0b64e6
Plasma Chain0x00000000B24D62781dB359b07880a105cD0b64e6
Unichain0x00000000B24D62781dB359b07880a105cD0b64e6
Degen Chain0x00000000B24D62781dB359b07880a105cD0b64e6