2.2.2 • Published 1 month ago

@stardust-collective/dag4 v2.2.2

Weekly downloads
1
License
MIT
Repository
github
Last release
1 month ago

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.

2.2.2

1 month ago

2.2.1

2 months ago

2.2.0

11 months ago

2.1.3

11 months ago

2.1.2

1 year ago

2.1.0-beta

1 year ago

2.1.1-beta

1 year ago

1.2.5

2 years ago

1.2.2-beta.2

2 years ago

1.2.4-beta.1

2 years ago

1.2.4-beta.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.4-es5.0

2 years ago

1.2.2-es5-beta.0

2 years ago

1.2.2-beta-0

2 years ago

1.2.0

2 years ago

1.2.0-beta.1

2 years ago

1.2.0-beta.0

2 years ago

1.2.0-beta.3

2 years ago

1.2.0-beta.2

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago