This repository contains sample code for you to get started with the Channels application in IOTA Streams.
You can find documentation for these examples on the IOTA documentation portal.
To get started you need Git and Rust installed on your device.
-
Clone this repository
git clone https://github.com/JakeSCahill/channels-examples cd channels-examples
-
Open the
src/main.rs
file and change the author's secret to something secure// REPLACE THE SECRET WITH YOUR OWN let mut author = Author::new("MYAUTHORSECRET");
-
Start the author and follow the prompts
cargo +nightly run --release --bin author
When you run this command for the first time, it may take a minute or two to download and compile the dependencies.
In the console, you should see something like the following:
Creating a new channel Channel published Channel address: XP9QADNJGJOJTOIZDOFAOFKXQADWDKTGEMHFBNOZ9HROIPMVWPBTCUPOVKUYRKKAAFQ9XDBVSJMDALVZJ Sending signed message Published signed message Now, in a new terminal window, use the subscriber to publish a `Subscribe` message on the channel cargo +nightly run --release --bin subscriber XP9QADNJGJOJTOIZDOFAOFKXQADWDKTGEMHFBNOZ9HROIPMVWPBTCUPOVKUYRKKAAFQ9XDBVSJMDALVZJ AEFYSYRVRKKW9CPBRMXHYDNJJWK KLKGMAAQGXPHEJLQKIPKYPHEAFE Enter the message identifier of the `Subscribe` message that was published by the subscriber:
-
Open the
bin/subscriber.rs
file, and change the subscriber's secret to something secure// REPLACE THE SECRET WITH YOUR OWN let mut subscriber = Subscriber::new("MYSUBSCRIBERSECRET", true);
-
Copy the
cargo run
command and paste it into a new terminal window to start the subscribercargo +nightly run --release --bin subscriber XP9QADNJGJOJTOIZDOFAOFKXQADWDKTGEMHFBNOZ9HROIPMVWPBTCUPOVKUYRKKAAFQ9XDBVSJMDALVZJ AEFYSYRVRKKW9CPBRMXHYDNJJWK KLKGMAAQGXPHEJLQKIPKYPHEAFE
The first argument is the channel address, the second argument is the
Announce
message identifier, and the third argument is theSignedPacket
message identifier.The subscriber needs all this information to get the messages from the channel.
-
Follow the prompts
In the console, you should see that the subscriber was able to subscribe to the channel and read the encrypted message.
Channels is an alpha project that is being developed as a built-in protocol of the Streams framework.
If you want to support the sample code in this repository, consider:
If you want to support the Streams project, please head over to the GitHub repository and take a look at the contribution guidelines.
If you want to get involved in discussions about this technology, or you're looking for support, go to the #streams-discussion channel on Discord.