sendMessage
method once the EVM transaction that called it successfully executes. Shortly after, the result will be available for consumption via Router’s messageResult
method.
Queries are synchronous and do not require a callback.
AuthorizePersonaAddress
system, built into Cardinal.
/tx/game/authorize-persona-address
0x356833c4666fFB6bFccbF8D600fa7282290dE073
sendMessage
method enables smart contracts to send messages to the game shard specified by the given namespace. The messageID must be the fully qualified name of the message. For Cardinal game shards, the fully qualified name is of the form “groupName.MessageName”. For example, the create-persona
message’s fully qualified name is persona.create-persona
. Messages without a specified custom group in Cardinal have a default group called “game”.
Parameter | Type | Description |
---|---|---|
personaTag | string | The persona tag to send the message as. You MUST have this persona tag tied to your EVM address via AuthorizePersonaAddress . |
message | bytes | ABI encoded message struct. |
messageID | string | Fully qualified message identifier. |
namespace | string | The namespace of the game shard to send the message to. |
Type | Description |
---|---|
bool | Indicates the success of the message being queued for sending. |
messageResult
method enables smart contracts to retrieve the result of a cross-shard message.
Parameter | Description |
---|---|
txHash | The hash of the EVM transaction that triggered the sendMessage call. |
Type | Description |
---|---|
bytes | ABI encoded result struct. |
string | Error string, if any. Empty string means no error. |
uint32 | A numeric value representing the result status. |
Code | Value | Meaning |
---|---|---|
Success | 0 | Transaction executed successfully. |
TxFailed | 1 | Transaction execution failed. |
NoResult | 2 | No result available for the operation. |
ServerUnresponsive | 3 | Game Shard is unresponsive. |
Unauthorized | 4 | Unauthorized access or action. |
UnsupportedTransaction | 5 | Transaction type is not supported. |
InvalidFormat | 6 | Data or format is invalid. |
ConnectionError | 100 | Error in establishing or maintaining a connection. |
ServerError | 101 | Internal error with the game shard. |
query
router method enables smart contracts to read data from a game shard specified by the given namespace.
Parameter | Type | Description |
---|---|---|
request | bytes | ABI encoded query request struct. |
resource | string | The resource identifier for the query. (query name) |
namespace | string | The namespace of the game shard. |
Type | Description |
---|---|
bytes | ABI encoded query result struct. |
query
and sendMessage
Router methods both take in a parameter of type bytes
. These bytes must be formed by ABI encoding a struct with the exact same field types as their Cardinal game shard counterparts.
For example:
If the Cardinal game shard defines this message input: