Skip to content

isabella232/rif-communications-js

 
 

Repository files navigation

RIF Communication lib.js

CircleCI Dependency Status standard-readme compliant js-standard-style Managed by tAsEgir

Library for decentralized communication build as part of RIF OS

Table of Contents

Install

npm

> npm install @rsksmart/rif-communications

Usage

Import the library

var RifCommunications = require('@rsksmart/rif-communications');

Initialization

// Create a key or load from a secure storage to skip this step
var key = await RifCommunications.createKey();

// Create peer id
var peerId = await RifCommunications.createPeerIdFromJSON(key);

// Create peer information
var peerInfo = await RifCommunications.createPeerInfo(peerId);

// Create your peer node
var node = RifCommunications.createNode(peerInfo, host, port, sendMsgFunc);

// Connect to a bootnode using a multiaddress string
await RifCommunications.connectToNode(node, BOOTNODE_ADDRESS);

Send a message to another peer

// Create recipient from their public key (<recipientID>)
var recipient = await RifCommunications.createPeerIdFromPublicKey(recipientID);

// Send a message
await RifCommunications.sendMsg(node, recipient, message, msgNonce);

API

Contribute

There are some ways you can make this module better:

  • Consult our open issues and take on one of them
  • Help our tests reach 100% coverage!

License

MIT

About

RIF Communication TypeScript library for developers

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.6%
  • JavaScript 2.4%