Gear protocol (which powers the Vara network) has a unique feature by design —the option to send and receive messages between any actors on the network. When we talk about actors, we talk about users, contracts, bridges, you name it. This technology allows not just a simple option of attaching a comment to the transaction you are sending to a friend but also gives you a chance to send a simple message to any address in the network as well as receive a message from the programs you are running or interacting with. For example:
This could become a decentralized messenger inside the wallet, taking the interaction of users to a different level.
An NFT like game where this NFT will send you a message, let’s say: feed me. You can send some gas to it or some other command, and it can change its appearance or mood, can grow or evolve in some form.
A Dex which can send price alerts and notifications similar to the pop-ups that are already widely common in our Web2 world.
The difference is that in our case, all this info will be decentralized and available in wallets, allowing users to interact much more often with it. Not only to send crypto to somebody, but it becomes a center of operation of the whole crypto ecosystem.
Your challenge
Create a proof of concept application that is built on Vara and uses SubQuery that allows a user to send and receive messages to other users or smart contracts
As a user, I want to construct and send a message, so that the other user can receive this message in their app
As a user, I want to view a list of messages that I’ve seen, so that i can decide what messages to respond to
As a user, I want to be able to respond to a message, to that the other user sees a reply
Technical Hints
There are 2 types of messages that you might want to index using SubQuery
Messages sent from the program to the user (events containing this type of message are called "UserMessageSent” from the GearMessenger pallet). The payload is:
id - message id
source - message sender
destination - message receiver
payload - message data
value - amount applied to message
reply - if the message is a response to another message, then the reply will contain the id of the message that was responded to as well as message processing exitCode. This field can be used to construct the history of messages
Messages sent from the user to the program (events containing this type of message are called “MessageQueued”). The structure of these messages differs from UserMessageSent messages like so:
To get the payload of a sent message, you need to get the data of the extrinsic associated with this event
This might be done with a separate request to SubQuery for performance
Each message includes a payload that is represented as bytes (in hex format).
The program metadata must be used to decode these bytes.
Metadata isn’t stored on the blockchain, so there are many options to get it. For example, it can be stored in some specific place connected to the application that you build
To send a message, you will want to call the following extrinsics in the GearMessenger pallet:
sendMessage - extrinsic to send messages to any actor
sendReply - extrinsic to send reply to a specific message
The Gear Mailbox contains messages waiting for user actions. Users can send replies to these messages or claim the value that is applied to these messages. To perform these actions, you can use @polkadot/api library or @gear-js/api library, which is actually a wrapper for @polkadot/api.
claimValueFromMailbox is extrinsic used to claim value
sendReply is extrinsic used to send reply to a particular message
Background
Gear protocol (which powers the Vara network) has a unique feature by design —the option to send and receive messages between any actors on the network. When we talk about actors, we talk about users, contracts, bridges, you name it. This technology allows not just a simple option of attaching a comment to the transaction you are sending to a friend but also gives you a chance to send a simple message to any address in the network as well as receive a message from the programs you are running or interacting with. For example:
The difference is that in our case, all this info will be decentralized and available in wallets, allowing users to interact much more often with it. Not only to send crypto to somebody, but it becomes a center of operation of the whole crypto ecosystem.
Your challenge
Create a proof of concept application that is built on Vara and uses SubQuery that allows a user to send and receive messages to other users or smart contracts
Technical Hints
There are 2 types of messages that you might want to index using SubQuery
To get the payload of a sent message, you need to get the data of the extrinsic associated with this event
To send a message, you will want to call the following extrinsics in the GearMessenger pallet:
The
Gear Mailbox
contains messages waiting for user actions. Users can send replies to these messages or claim the value that is applied to these messages. To perform these actions, you can use @polkadot/api library or @gear-js/api library, which is actually a wrapper for @polkadot/api.An example of all the above is https://idea.gear-tech.io/explorer/0x94843ce3d3e1a5e887b2e618835d2013d90c9fe483f35af943cefb69c603d66c?node=wss%3A%2F%2Farchive-node.gear-tech.io