Giter VIP home page Giter VIP logo

dag4.js's Introduction

DAG4 - DAG JavaScript API

This is the DAG JavaScript API for Constellation Network.

Please read the documentation for more detailed instructions. The following includes basic install and configuration.

Installation

Node

npm install @stardust-collective/dag4

Yarn

yarn add @stardust-collective/dag4

Usage

// In Node.js
const fetch = require('node-fetch');
const { dag4 } = require("@stardust-collective/dag4");

dag4.di.useFetchHttpClient(fetch);
dag4.network.config({
    beUrl: 'https://block-explorer.constellationnetwork.io',
    lbUrl: 'http://lb.constellationnetwork.io:9000'
})

Now you can use it to:

// Get latest snapshot from the block explorer
dag4.network.blockExplorerApi.getLatestSnapshot();

// Get the total supply from a validator node
dag4.network.loadBalancerApi.getTotalSupply();

Usage with TypeScript

We support types within the repo itself. Please open an issue here if you find any wrong types.

You can use dag4.js as follows:

import dag4

import { dag4 } from '@stardust-collective/dag4';

Configure Network

import fetch from 'node-fetch';

dag4.di.useFetchHttpClient(fetch);
dag4.network.config({
   beUrl: 'https://block-explorer.constellationnetwork.io',
   lbUrl: 'http://lb.constellationnetwork.io:9000'
})

If you are using the types in a commonjs module, like in a Node app, you have to enable esModuleInterop and allowSyntheticDefaultImports in your tsconfig for typesystem compatibility:

"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    ....

Documentation

Documentation can be found at Wiki.

Building

Requirements

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

Building (DAG4)

Build the dag4.js package:

npm run build

Testing (mocha)

npm test

Community


License

License: GPL v3 This project is licensed under the terms of the MIT license.

dag4.js's People

Contributors

ffox77 avatar kalkiboru111 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.