{"id":23265082,"url":"https://github.com/beingmohit/libp2p-rpc","last_synced_at":"2025-08-20T20:33:51.329Z","repository":{"id":26895549,"uuid":"110693742","full_name":"beingmohit/libp2p-rpc","owner":"beingmohit","description":":satellite: A libp2p node with rpc using protocol buffers","archived":false,"fork":false,"pushed_at":"2022-12-07T23:34:49.000Z","size":423,"stargazers_count":16,"open_issues_count":10,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T11:43:20.637Z","etag":null,"topics":["libp2p","p2p","protocol-buffers","rpc"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beingmohit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-14T13:27:59.000Z","updated_at":"2024-08-03T21:49:47.000Z","dependencies_parsed_at":"2022-07-27T08:52:33.477Z","dependency_job_id":null,"html_url":"https://github.com/beingmohit/libp2p-rpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingmohit%2Flibp2p-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingmohit%2Flibp2p-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingmohit%2Flibp2p-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beingmohit%2Flibp2p-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beingmohit","download_url":"https://codeload.github.com/beingmohit/libp2p-rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230231381,"owners_count":18193922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["libp2p","p2p","protocol-buffers","rpc"],"created_at":"2024-12-19T15:16:58.852Z","updated_at":"2024-12-19T15:16:59.897Z","avatar_url":"https://github.com/beingmohit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libp2p-rpc\n\nlibp2p-rpc provides peer to peer RPC built on top of [`LibP2P`](https://github.com/libp2p/js-libp2p/). It takes care of everything you need to do to build peer 2 peer application, from peer discovery to protocol handshake. Simply define your protocol in protocol buffers .proto file and get started. \n\nlibp2p-rpc is essentially a [`libp2p-node`](https://github.com/libp2p/js-libp2p/). It connects to peers on tcp and websocket, discovers peers by railing and multicast dns. Then it establishes end to end encrypted connection with peers and does protocol handshake. [`Protocol Buffers`](https://developers.google.com/protocol-buffers/) is used for serialization \u0026 messsage validation.\n\n#### Install\n```\nnpm install libp2p-rpc --save\n```\n#### Getting Started\n\nDefine your RPC protocol in .proto file. Checkout [`Protocol Buffers`](https://developers.google.com/protocol-buffers/)  for more info.\n```\nsyntax = \"proto3\";\n\nservice Protocol {\n    rpc sayHello (HelloRequest) returns (HelloReply) {}\n}\n\nmessage HelloRequest {\n    string name = 1;\n}\n\nmessage HelloReply {\n    string message = 1;\n}\n```\n\nJavascript Code\n\n```\nconst fs = require('fs')\nconst path = require('path')\nconst protobuf = require('protobufjs')\nconst PeerInfo = require('peer-info')\nconst Node = require('libp2p-rpc')\n\nconst config = {\n    name: 'your-protocol-name',  // Protocol name used for handshake\n    version: '1.0.0',            // Protocol version used for handshake\n    service: 'Protocol',         // Name of service in .proto file\n    bootstrapers: [],            // Bootstrapping nodes \n    multicastDNS: {  \n        // multicastDNS options\n        interval: 1000   \n    }\n}\n\n// PeerInfo creates public-private keypair used for connection encryption and peer identity.\nPeerInfo.create((err, peerInfo) =\u003e {\n    if (err) \n        throw new Error(err)\n    \n    // Load your .proto file\n    protobuf.load(path.join(__dirname, './protocol.proto')).then((root) =\u003e {\n    \n        // Create Node\n        const node = new Node(peerInfo, root, config)\n        \n        // Event fires when a peer connects\n        node.on('peer:connection', (conn, peer, type) =\u003e {\n            console.log('peer:connection')\n    \n            // Make RPC call to peer\n            peer.rpc.sayHello({name: 'Foo'}, (response, peer) =\u003e {\n                console.log('Response', response)\n            })\n        })\n        \n        // Define RPC handlers\n        node.handle('sayHello', (message, peer, respond) =\u003e {\n            console.log('Request', message)\n            respond({ message: 'heyThere' })\n        })\n        \n        // Lets starts node\n        node.start().then(console.log, console.error) \n        \n    }, console.error)\n})\n```\n\nCheckout [`https://github.com/libp2p/js-libp2p/`](https://github.com/libp2p/js-libp2p/) for more into\n### LibP2P Modules Used\n\n| Package |\n|---------|\n| **Transports**|\n| [`libp2p-tcp`](//github.com/libp2p/js-libp2p-tcp) | \n| [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | \n| **Stream Muxers**|\n| [`libp2p-spdy`](//github.com/libp2p/js-libp2p-spdy) | \n| **Discovery**|\n| [`libp2p-mdns-discovery`](//github.com/libp2p/js-libp2p-mdns-discovery) | \n| [`libp2p-railing`](//github.com/libp2p/js-libp2p-railing) | \n| **Crypto Channels** |\n| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | \n| **Peer \u0026 Content Routing** |\n| [`libp2p-kad-dht`](//github.com/libp2p/js-libp2p-kad-dht) | \n\n### Contributions\n\nAll contributions are welcome. Create Issue, Discuss, Submit PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeingmohit%2Flibp2p-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeingmohit%2Flibp2p-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeingmohit%2Flibp2p-rpc/lists"}