Skip to content

The DAV JavaScript library eases interaction between Captains and the DAV network

License

Notifications You must be signed in to change notification settings

mariolo1985/dav-js

 
 

Repository files navigation

DAV-JS SDK

Gitter chat license

The DAV JavaScript SDK eases integration of JavaScript, TypeScript, and Node.js code with the DAV Network.

Sample Code

The following sample shows how an electic boat might define a statement of need for charging services. Typically this will be sent by a boat that is looking for a charging station around certain coordinates that can accommodate it.

This request is sent to the discovery engine which broadcasts the need to DAV identities that can provide this service. Bids are later received in response.

const { SDKFactory } = require('dav-js');
const { NeedParams, enums } = require('dav-js/dist/vessel-charging');
const DAV = SDKFactory({
  apiSeedUrls,
  kafkaSeedUrls,
});
const boat = await DAV.getIdentity(boatDavId);

const needParams = new NeedParams({
  location: {
    lat: 32.050382,
    long: 34.766149,
  },
  radius: 20,
  startAt: 1538995253092,
  dimensions: {
    length: 50,
    width: 15,
    height: 20,
  },
  weight: 50000,
  batteryCapacity: 4,
  currentBatteryCharge: 45,
  energySource: enums.EnergySources.Solar,
  amenities: [enums.Amenities.Docking],
});
const need = await boat.publishNeed(needParams);

A full working sample can be seen in the DAV developer portal.

About

The DAV JavaScript library eases interaction between Captains and the DAV network

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.3%
  • JavaScript 1.6%
  • Other 0.1%