An API for dApp frontends to communicate with the RChain blockchain.
The RChain Cooperative is developing a decentralized, economically sustainable public compute infrastructure. Decentralized applications or "dApps" will run their business logic as smart contracts on the blockchain. Their user interfaces will be more traditional programs that interact with the blockchain as a backend. This separation allows dApp developers to create nice abstract interfaces, and allows end users to create their own sovereign interfaces should they choose to do so.
Install with npm install rchain-community/rchain-api
. Then, with
rnode on localhost
, you can get current block info:
const grpc = require('grpc');
const { RNode, Ed25519keyPair, Hex, REV } = require('rchain-api');
const rnode = RNode(grpc, { host: 'localhost', port: 40401 });
rnode.showBlocks()
.then((blocks) => { assert.ok(blocks[0].blockHash); });
If your node is a validator and you have a key to authorize payment, you can deploy code:
const grpc = require('grpc');
const { RNode, Ed25519keyPair, Hex, REV } = require('rchain-api');
const rnode = RNode(grpc, { host: 'localhost', port: 40401 });
const term = '@"world"!("Hello!")';
const myKey = Ed25519keyPair(Hex.decode('11'.repeat(32)));
const timestamp = new Date('2019-04-12T17:59:29.274Z').valueOf();
const info = REV.SignDeployment.sign(myKey, { timestamp, term, phloLimit: 10000, phloPrice: 1 });
rnode.doDeploy(info, true).then((message) => { assert(message.startsWith('Success')); });
Choices include:
- RChain testnet nodes such as
node4.testnet.rchain-dev.tk
- a community node at
rnode-test.rhobot.net
- running your own RNode
protobuf: v0.9.1 bf1b2c6 Mar 28, 2019
- Nth Caller a minimal RChain-based dApp game that uses RChain-API
- Status a moderately complex dapp that uses more RChain-API features as well as RSign
- Coin Faucet An advanced robust dApp that use raspberry PI to airdrop tokens to devices in physical proximity
- RChain-dbr A web-of-trust based distributed budgeting and rewards dApp
- RSign A chrome extension for generating client-side signatures akin to metamask
- node-client A similar but less mature RChain API written in python
Copyright 2018-2019 RChain Cooperative
Apache 2.0 License (See LICENSE.txt)
Contributions welcome (See CONTRIBUTING.md)