Introduction

Implementation

This page will go step by step from implementing the libraries to register your channels in the app


Implementation

To broadcast a message simply:

import { Channel } from "@aurelianoa/iris-channels/contracts/channel/Channel.sol";

contract MyChannel is Channel {
  
  function foo() {
    /// your logic

    /// broadcast the message
    address networkAddress = "0x...."
    string memory myEventIndex = "myEventIndex"
    bytes memory data = abi.encode("my data");

    broadcast(networkAddress, myEventIndex, data);
  }

}

If there is no bytes memory data to send, it can simply use a an empy string

Important!

To get the networkAddress got to our app and register your network.

To receive the message simply:

import { Listener } from "@aurelianoa/iris-channels/contracts/listener/Listener.sol";

contract MyListener is Listener {
  
  /// Override the onReceivedMessage function
  function onReceivedMessage(address sender, string memory eventIndex, bytes memory data) internal override {
        if(isChannelAvailable(sender) && compareIndex(eventIndex, "myEventIndex")) {
            /// process the data if theres any
            /// your logic here
        }
    }
}

The onReceiveMessage function needs to be override to catch and process the message.

Important!

The isChannelAvailable and compareIndex are helper functions from the contract Listener to verify is the uncoming message is legit. This is intended to trigger different logics depending of the message received.


Manage your Network

Managing your netwrok is very simple. Just jump into our app and get a channel registry spot to start registering your first network (channel + listeners).

Get a channel registry spot

Go to plans in the app and after connecting your wallet select the best plan that fits.

get plans

You should know!

The plan is tied to the wallet that made the purchase. And only that wallet is allowed to manage the channels on the app. We are developing better ways to get and manage plans to different ways such CC payments and api key usage.

Register your first Channel

After implenting the iris-channels in your channel and listener smart contracts and getting a plan, go to the channels section and register your first channel.

channels

Click on "Add Channel"

new channel

You should know!

You can register your first channel and then add the listener(s) later. Your channel smart contract will broadcast the message even if there is no listeners registered.

Add Listeners to your Channel

If you want to register more listeners to your channel just click any channel from your channels section and then click the option "Add Listeners"

channel listeners

Click on "Add Listeners"

add listeners

You should know!

Also you can remove any previous added listener any time without breaking the flow of the network. Same applies to adding a new listener later on.

Previous
Getting started