Giter VIP home page Giter VIP logo

holochain-client-js's Introduction

Project Forum License: CAL 1.0 Test Twitter Follow

Holochain Client - JavaScript

A JavaScript client for the Holochain Conductor API (works with browsers as well as Nodejs).

Holochain's Conductor API is under active development. This client package tracks that development fairly closely but sometimes gets behind.

Installation

To install from NPM, run

npm install --save-exact @holochain/client

This code is under beta development and you may wish to lock to an exact version of the library for that reason, as shown in the above command.

Sample usage

Use AdminWebsocket

  const admin = await AdminWebsocket.connect(`ws://127.0.0.1:8000`, TIMEOUT)
  const agentPubKey = await admin.generateAgentPubKey()

Use AppWebsocket with implicit zome call signing

  const signalCb = (signal: AppSignal) => {
    // impl...
    resolve()
  }

  const TIMEOUT = 12000
  // default timeout is set to 12000
  const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, TIMEOUT, signalCb)

  // default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
  await client.callZome({
   cell_id,
   zome_name: "test_zome",
   fn_name: 'test_emitter_fn',
   provenance: agentPubKey,
   payload: null,
  }, 30000)

Use AppAgentWebsocket

  const signalCb = (signal: AppSignal) => {
    // impl...
    resolve()
  }

  const TIMEOUT = 12000
  // default timeout is set to 12000
  const appWs = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, 12000, signalCb)

  const client = new AppAgentWebsocket(appWs, 'installed_app_id')

  // default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
  await client.callZome({
   role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client
   zome_name: "test_zome",
   fn_name: 'test_emitter_fn',
   payload: null,
  }, 30000)

API Reference

See docs/API.md

Holochain Compatibility

See default.nix for the Holochain version this package is compatible with.

If updating the Holochain version included in holonix, please use niv update as explained in the Holochain Installation Guide.

Running tests

You need a version (stable toolchain) of Rust available.

You need holochain and hc on your path, best to get them from nix with nix-shell.

To perform the pre-requisite DNA compilation steps, and run the Nodejs test, run:

nix-shell
./run-test.sh

Contribute

Holochain is an open source project. We welcome all sorts of participation and are actively working on increasing surface area to accept it. Please see our contribution guidelines for our general practices and protocols on participating in the community, as well as specific expectations around things like code formatting, testing practices, continuous integration, etc.

  • Connect with us on our forum

License

License: CAL 1.0

Copyright (C) 2020-2023, Holochain Foundation

This program is free software: you can redistribute it and/or modify it under the terms of the license provided in the LICENSE file (CAL-1.0). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

holochain-client-js's People

Contributors

alastairong avatar connoropolous avatar ddd-mtl avatar freesig avatar guillemcordoba avatar jetttech avatar jost-s avatar maackle avatar matthme avatar mhuesch avatar mjbrisebois avatar peeech avatar philipbeadle avatar robbiecarlton avatar thedavidmeister avatar timotree3 avatar weswalla avatar zippy avatar zo-el avatar

Stargazers

 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.