Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dashevo/dapi-grpc

Package Overview
Dependencies
Maintainers
0
Versions
369
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dashevo/dapi-grpc

DAPI GRPC definition file and generated clients

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
577
increased by27.94%
Maintainers
0
Weekly downloads
 
Created
Source

DAPI GRPC

Build Status NPM version Release Date license

Decentralized API GRPC definition files and generated clients

Table of Contents

Install

Ensure you have the latest NodeJS installed.

From repository

Clone the repo:

git clone https://github.com/dashevo/dapi-grpc

Install npm packages:

npm install
From NPM
npm install @dashevo/dapi-grpc

Usage

Node users are able to access exported elements by requiring them under v0 property.

Core Client

Provide a client to perform core request.

const {
  v0: {
    CorePromiseClient,
  },
} = require('@dashevo/dapi-grpc');

const client = new CorePromiseClient(url);

Provided method allow to then perform the request, by passing a specific request parameter (see below example). All methods share the same API :

  • First parameter expect a specific request instance of a Request class (such as GetBlockRequest, GetTransactionRequest).
  • Second parameter is optional for metadata object.
  • Third parameter is optional for options.

Here is a usage example for requesting a Block by its hash and handling its response :

const {
  v0: {
    CorePromiseClient,
    GetBlockRequest,
    GetBlockResponse,
  },
} = require('@dashevo/dapi-grpc');

const client = new CorePromiseClient(url);

async function getBlockByHash(hash, options = {}) {
  const getBlockRequest = new GetBlockRequest();
  getBlockRequest.setHash(hash);

  const response = await client.getBlock(
    getBlockRequest,
    {},
    options,
  );
  const blockBinaryArray = response.getBlock();

  return Buffer.from(blockBinaryArray);
}

Available methods :

  • getStatus
  • getBlock
  • broadcastTransaction
  • getTransaction
  • getEstimatedTransactionFee
  • subscribeToBlockHeadersWithChainLocks
  • subscribeToTransactionsWithProofs

For streams, such as subscribeToTransactionsWithProofs and subscribeToBlockHeadersWithChainLocks, a grpc-web stream will be returned. More info on their usage can be read over their repository.

Platform Client

Provide a client to perform platform request. Method's API and usage is similar to CorePromiseClient.

const {
  v0: {
    PlatformPromiseClient,
  },
} = require('@dashevo/dapi-grpc');

const client = new PlatformPromiseClient(url);

Available methods :

  • broadcastStateTransition
  • getIdentity
  • getDataContract
  • getDocuments
  • getIdentitiesByPublicKeyHashes
  • waitForStateTransitionResult
  • getConsensusParams
  • setProtocolVersion

Maintainer

@shumkov

Contributing

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Dash Core Group, Inc.

FAQs

Package last updated on 27 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc