Meow
API documentation for meow-app. Meow is a twitter like (but peer to peer) application built on top of zChain. This means that the application "extends" upon the zChain core functionality in terms of message passing and persistance accross nodes. Implementation can be found at https://github.com/zer0-os/zChain/tree/main/apps/meow.

Table of Contents

  • Initialize a meow
    • init(zIdName, listenAddrs?)
  • Public Instance Methods
    • meow.startDaemon(zIdName, listenAddrs?)
    • meow.load()
    • meow.sendMeow(message, publishOnTwitter = false, network?)
    • meow.sendMessage (message: string, channel: string, network?: string)
    • meow.setDisplayName(peerId, name, force)
    • meow.followZId(peerIdOrName)
    • meow.unfollowZId(peerIdOrName)
    • meow.getPeerFeed(peerIdOrName, n)
    • meow.getFollowedPeers()
    • meow.followChannel(channel)
    • meow.unFollowChannel(channel)
    • meow.getFollowedChannels()
    • meow.getChannelFeed(channel, n)
    • meow.listDBs()
    • meow.enableTwitter(force)
    • meow.disableTwitter()
    • meow.help()
    • meow.createNetwork(networkName: string, channels: string[])
    • meow.getNetworkMetadata(networkName: string)
    • meow.addChannelInNetwork(networkName: string, channel: string)
    • meow.joinNetwork(networkName: string)
    • meow.leaveNetwork(networkName: string)
    • meow.getNetworkList()
    • meow.getMyNetworks()

Initialize a meow

init(zIdName, listenAddrs)

1
const meow = new MEOW();
2
await meow.init('node-a', [ '/ip4/0.0.0.0/tcp/0', .. ]);
Copied!
Under the hood it's using the zchain.initialize(..) method to initialize an ipfs node and the databases. Check zChain.initialize() method in zchain API documentation for more details. Along with initializing zChain, we:
  • Intialize the meow storage (built/extended on top of zChain storage)
  • Intialize twitter client (if enabled)
  • Logic for new connections :: In every 10s (setInterval) try to find & connect with new peers (using a relay)
  • Logic for following/unfollowing peer :: After connecting, check in the database if we're following this peer, if yes, then open a connection stream and request it's feed db address.
Arguments
Descriptions
zIdName (string)
zId Name assigned to this node by the end user
listenAddrs (string[], optional)
Additional multiaddrs this node can listen to.

Public Instance Methods

meow.startDaemon(zIdName, listenAddrs?)

Runs zchain.startDaemon(). After which we log the discovery and connections, and listen for new messages (to topics we have been subscribed to). This is specific to the CLI right now.
1
const meow = new MEOW();
2
const daemon = await meow.startDaemon('my-daemon');
Copied!

meow.load()

Connects to the ipfs daemon and loads the databases. Specific to the CLI right now.

meow.sendMeow(message, publishOnTwitter = false, network?)

Send a meow (a message), across hashtags on a network. By default each message is published on #everything channel. A node will receive all messages if it's following the #everything channel (becoming a super node). Additionally, if twitter is enabled, then the message will also be published on #zero channel.
NOTE: If network name is not passed, then default network 0://default.network will be used.
Arguments
Descriptions
message (string)
The message to publish.
publishOnTwitter (boolean, optional)
This is set to false by default. If twitter is enabled and this is set to true, then the message will also be published on twitter.
network (string, optional)
Network name.
Usage:
1
// publishes message on #fairtoplay, #ucl, #everything
2
await meow.sendMeow(`Thrilled to join the football gaming revolution
3
with @UFLgame bringing the new #fairtoplay experience to
4
football gamers worldwide! See you in the Game soon! #ucl`);
Copied!

meow.sendMessage (message: string, channel: string, network?: string)

Send a message (allowed up to 280 char) on a channel at a network. The published message is stored in the zchain feed database, and the public topic database of orbit-db.
NOTE: If network name is not passed, then default network 0://default.network will be used.
Arguments
Descriptions
message (string)
The message to publish.
channel (string)
The channel name (must be present in network).
network (string, optional)
Network name.
Usage:
1
// send message
2
await meow.sendMessage(`Hello Friend`, '#zero', '0://wilder.team');
Copied!

meow.setDisplayName(peerId, name, force)

Sets a name of the peerId in the local address book. Throws an error if force is false and a display name is already present for a peerID.
Arguments
Descriptions
peerId (string)
The peerID (as base58 encoded string).
name (string)
Display name to set for this peerID.
force (boolean, optional)
If true, updates the displayName for a peer, if it has already set previously.
Usage:
1
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
2
3
// set display name for ratik peerID in local address book
4
await meow.setDisplayName(ratikId, "ratik");
5
6
// update display name to new one for the peer
7
await meow.setDisplayName(ratikId, "ratik-new", true);
Copied!

meow.followZId(peerIdOrName)

Follow a zId (peerID). After you follow a peer, an entry is saved to followingzIds databases. And upon establishing connection with the peer you follow, we exchange that peer's (unique) database address (it's local feed database). This way we sync up on the messages published by that peer (as we have a local copy of it's peer database now).
Arguments
Descriptions
peerIdOrName (string)
The peerID (as base58 encoded string) or the display name from the local address book.
Usage:
1
// follow ratik
2
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
3
await meow.followZId(ratikId);
4
5
// or follow by name
6
await meow.set(ratikId, "ratik"); // set in local address book
7
await meow.followZId("ratik");
Copied!

meow.unfollowZId(peerIdOrName)

Unfollow a zId (peerID). After you unfollow a peer, entry of the peer is removed from followingZIds database, and local feed database of the peer we have unfollowed is dropped.
Arguments
Descriptions
peerIdOrName (string)
The peerID (as base58 encoded string) or the display name from the local address book.
Usage:
1
// unfollow ratik
2
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
3
await meow.unfollowZId(ratikId);
4
5
// or unfollow by name
6
await meow.set(ratikId, "ratik"); // set in local address book
7
await meow.unfollowZId("ratik");
Copied!

meow.getPeerFeed(peerIdOrName, n)

Displays last "n" messages published by a peer. Please note that you must be "following" the peer and established connection to it atleast once (so that you have that peer's feed unique database address).
Arguments
Descriptions
peerIdOrName (string)
The peerID (as base58 encoded string) or the display name from the local address book.
n (number)
Number of messages to display.
Usage:
1
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
2
await meow.set(ratikId, "ratik"); // set in local address book
3
4
// display last 5 messages followed by ratik
5
await meow.getPeerFeed("ratik", 5);
Copied!

meow.getFollowedPeers()

Returns the peers(zId's) this node is following. If a display name is set for any peer, that will be returned as well.
1
// list following peers
2
const peers = meow.getFollowedPeers();
3
console.log('peers: ', peers);
Copied!

meow.followChannel(channel, network?)

Follow a channel on a network. After following a channel, any message published on that channel will be received by this node. You also open & load the public (orbitdb) database of this channel, so that you receive/replicate the persisted messages even whenever the node goes offline.
NOTE: If network name is not passed, then default network 0://default.network will be used.
Arguments
Descriptions
channel (string)
Name of the channel (must be present in network) to follow
network (string, optional)
Name of the network.
Usage:
1
// follow a channel in network 0://wilder.team
2
await meow.followChannel('#fairtoplay', '0://wilder.team');
Copied!

meow.unFollowChannel(channel, network?)

Unfollow a channel on a network. After unfollowing a channel, you will no longer receive any message published on that channel. The public database of that channel is also dropped from the local system.
NOTE: If network name is not passed, then default network 0://default.network will be used.
Arguments
Descriptions
channel (string)
Name of the channel (must be present in network) to unfollow
network (string, optional)
Name of the network.
Usage:
1
// unfollow a channel
2
await meow.unFollowChannel('#fairtoplay', '0://wilder.team');
Copied!

meow.getFollowedChannels()

Returns a list of the channels this node is following.
1
// list the channels this node is following
2
const channels = meow.getFollowedChannels();
3
console.log('channels: ', channels);
Copied!

meow.getChannelFeed(channel, n, network?)

Returns last "n" messages published "on" a channel in a network. Please note that you must be "following" the channel in order to view it's feed.
NOTE: If network name is not passed, then default network 0://default.network will be used.
Arguments
Descriptions
channel (string)
Name of the channel (must be present in network) to display feed of.
n (number)
Number of messages to display.
network (string, optional)
Name of the network.
Usage:
1
// display last 3 messages on channel #ucl on network 0://wilder.team
2
const feed = await meow.getChannelFeed('#ucl', 3, '0://wilder.team');
3
console.log('Channel Feed: ', feed);
Copied!

meow.listDBs()

Lists all the databases in an object, with their respective orbit-db addresses and the no. of entries. Databases listed are:
  • followingZIds: key value store for storing following peers
  • followingChannels: key value store for storing the channels we're following.
  • Peer Feeds: List of feed databases (address, entries) for each peer we're following.
  • Channel feeds: List of channel databases (address, entries) for each channel we're following.
1
await meow.listDBs()
Copied!

meow.enableTwitter(force)

Enables twitter. A window is open first on the browser, where the user is asked to authorize meow app to tweet of behalf of the user. After authorization by user, the meow app has read & write permissions for tweets from your twitter account. The config for twitter account is saved at ~/.zchain/twitter-config.json.
If you want to "tweet" from a meow, pass true with sendMeow function (eg below).
Arguments
Descriptions
force (boolean)
If passed, user is asked to authorize again.
Usage:
1
await meow.enableTwitter();
2
3
// send message to zchain + post a tweet to twitter.
4
await meow.sendMeow("post from zchain", true);
Copied!

meow.disableTwitter()

Disables twitter. Simply removes config at ~/.zchain/twitter-config.json
1
await meow.disableTwitter();
Copied!

meow.help()

Displays a list of available functions withing the meow API.

meow.createNetwork(networkName: string, channels: string[])

Creates a new network, with an initial list of channels. By default channel #general is added to each network. You automatically subscribe to all channels associated with the network after it's creation. Each network must be "globally unique". To ensure this, the peerID adding the new network, must have an ethereum address and signature added in zchain. And the name must be a valid ZNA, from the list of ZNA's associated with the peer's ethereum address. This will soon be replaced by ZNS.
Arguments
Descriptions
networkName (string)
Name of the network to create.
channels (string[])
List of channels associated with this network.
Usage:
1
// create a new network
2
meow.createNetwork('0://wilder.team', [ "#zero", "#random" ]);
Copied!

meow.getNetworkMetadata(networkName: string)

Get the data associated with the network. Returns the associated list of channels with this network, and the associated peerID.
Arguments
Descriptions
networkName (string)
Name of the network to get meta data of.
Usage:
1
const metaData = meow.getNetworkMetadata('0://wilder.team');
2
console.log("meta: ", metaData);
Copied!

meow.addChannelInNetwork(networkName: string, channel: string)

Add a new channel in network. Returns `void` if channel is already present in network.
Arguments
Descriptions
networkName (string)
Name of the network to add a new channel in.
channel (string)
Channel to add.
Usage:
1
await meow.addChannelInNetwork('0://wilder.team', "#announcements");
Copied!

meow.joinNetwork(networkName: string)

Join a new network. As a join, you also subsribe/follow all the channels present in the network.
Arguments
Descriptions
networkName (string)
Name of the network to join.
Usage:
1
await meow.joinNetwork('0://wilder.team');
Copied!

meow.leaveNetwork(networkName: string)

Leave a network. As a leave, you also unsubsribe/unfollow all the channels present in the network.
Arguments
Descriptions
networkName (string)
Name of the network to leave.
Usage:
1
await meow.leaveNetwork('0://wilder.team');
Copied!

meow.getNetworkList()

Returns a list of "all" networks + associated channels.
1
const allNetworks = await meow.getNetworkList();
2
console.log("All Networks: ", allNetworks);
Copied!

meow.getMyNetworks()

Returns a list of network + associated channels "this" peer is following.
1
const myNetworks = await meow.getMyNetworks();
2
console.log("My Networks: ", myNetworks);
Copied!
Last modified 13d ago