@stardust-collective/dag4-core v2.2.2
DAG4 - Constellation Hypergraph JavaScript API
This is the Constellation Hypergraph JavaScript API.
You need to run a local or remote Hypergraph node to use this library.
Please read the documentation for more.
Installation
Node
npm install @stardust-collective/dag4
Yarn
yarn add @stardust-collective/dag4
build using the dag4.js repository:
npm run build
Usage
// In Node.js
const fetch = require('node-fetch');
const dag4 = require("@stardust-collective/dag4");
dag.di.useFetchHttpClient(fetch);
dag.network.config({
beUrl: 'https://block-explorer.constellationnetwork.io',
lbUrl: 'http://lb.constellationnetwork.io:9000'
})
Now you can use it:
// Get latest snapshot from the block explorer
dag.network.blockExplorerApi.getLatestSnapshot();
// Get the total supply from a validator node
dag.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 { dag } from '@stardust-collective/dag4';
Configure Network
import fetch from 'node-fetch';
dag.di.useFetchHttpClient(fetch);
dag.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 just have to enable esModuleInterop
and allowSyntheticDefaultImports
in your tsconfig
for typesystem compatibility:
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
....
Documentation
Documentation can be found at Gitbook.
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
1 month ago
2 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago