npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

atn-lib

v0.3.0-alpha

Published

a light client lib for Dbot

Downloads

17

Readme

atn-lib v0.3.0-alpha

A light client lib for consumer to call ATN AI services.

Installation

Using npm:

$ npm i --save atn-lib
$ npm i --save [email protected]

In Node.js:

var AtnLib = require('atn-lib');
const lib = new AtnLib(
  "yourPrivateKey",        // private key 
  "rpcProvider"          // host and port Parity/Geth serves RPC requests on
);

Note: Your account should be existed in Kovan.

Usage

µraiden

Step 1: Getting all AI info lib.getAiList()

Step 2: Choosing an AI to use lib.getAiInfo(aiId)

Step 3: Opening a transfer channel lib.openChannel(aiInfo.dbot_receiver, deposit)

Step 4: Getting the price of the AI lib.getPrice(aiInfo.dbot_url, aiInfo.name)

Step 5: Calling the AI

lib.callAI(
      aiInfo.dbot_url,
      aiInfo.name,
      input,
      aiInfo.dbot_receiver,
      block,
      balance,
      fee
    );

smart contract

Step 1: Getting all AI info lib.getAiList()

Step 2: Choosing an AI to use lib.getAiInfo(aiId)

Step 3: Calling the AI lib.directlyCallAI(aiInfo.name, aiInfo.bill_kovan_addr, input)

Example

see in simple.js

API in Detail

getAiList

lib.getAiList()

Parameters

none

Returns

Array: The list of all AI:

  • AI Object
    • id-Number: The id of AI
    • type-String: The type of AI
    • name-String: The name of AI
    • bill_type-String: The bill type of AI
      • '0': free
      • '1': times
      • '2': interval
    • bill_kovan_addr-String: The address of billing contract in Kovan
    • dbot_url-String: Host and port dbot serves requests on
    • dbot_receiver-String: The address of dbot provider
    • params-String: The AI's parameters
      • name-String: The key of parameter
      • type-String: The type of parameter
      • required-Number: The parameter is required or not
        • 1: required
        • 0: options

getAiInfo

lib.getAiInfo(id)

Parameters

id-Number: The id of AI

Returns

AI Object

openChannel

lib.openChannel(receiver, deposit)

Parameters

  1. receiver-String: The address of dbot provider

  2. deposit-Number: Deposit value(number of ATN)

Returns

Result: The opened channel info

  • 0: The key of channel
  • 1: The balance of deposit value
  • 2: Settle block number of closing requests
  • 3: Closing balance of closing requests
  • 4: Opening block number
  • 5: The address of receiver
  • 6: The address of sender

topUpChannel

lib.topUpChannel(receiver, block, deposit)

Parameters

  1. receiver-String: The address of dbot provider
  2. block-Number: Opening block number
  3. deposit-Number: Topup value(number of ATN)

Returns

Result: The topup channel info

getChannels

lib.getChannels(dbot_url, block, status)

Parameters

  1. dbot_url-String: Host and port dbot serves requests on
  2. block(options)-Number: Opening block number
  3. status(options)-String:
  • all: all status channels
  • open/opened(default): opened channels
  • closed: closed channels

Returns

channel info:

  • receiver: The address of dbot provider
  • sender: The address of sender
  • deposit: Deposit value(number of ATN) of the channel
  • open_block_number: Opening block number
  • balance: The number of ATN which the channel used

closeChannel

lib.closeChannel(dbot_url, receiver, block, balance)

Parameters

  1. dbot_url-String: Host and port dbot serves requests on
  2. receiver-String: The address of dbot provider
  3. block-Number: Opening block number
  4. balance-Number: The number of ATN which the channel used

Returns

receipt: The receipt of close channel

getPrice

lib.getPrice(dbot_url, ai_name)

Parameters

  1. dbot_url-String: Host and port dbot serves requests on
  2. ai_name-String: The name of AI

Returns

fee: The cost of calling AI

callAI

lib.callAI(dbot_url, ai_name, input, receiver, block, balance, price)

Parameters

  1. dbot_url-String: Host and port dbot serves requests on
  2. ai_name-String: The name of AI
  3. input-Object: An object build with ai parameters
  4. receiver-String: The address of dbot provider
  5. block-Number: Opening block number
  6. balance-Number: The number of ATN which the channel used
  7. price-Number: The cost of calling AI

Returns

Result: The result of calling AI

directlyGetPrice

lib.directlyGetPrice(ai_name)

Parameters

  1. ai_name-String: The name of AI

Returns

fee: The cost of calling AI

directlyCallAI

lib.directlyCallAI(ai_name, bill_addr, input)

Note: In this way, you should use ws interface to init the lib

Parameters

  1. ai_name-String: The name of AI
  2. bill_addr-String: The address of billing contract in Kovan
  3. input-Number: An object build with ai parameters

Returns

Result: The result of calling AI