GithubHelp home page GithubHelp logo

jawaragordon / js-algorand-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from algorand/js-algorand-sdk

0.0 0.0 0.0 7.84 MB

The official JavaScript SDK for Algorand.

Home Page: https://algorand.github.io/js-algorand-sdk/

License: MIT License

Shell 0.34% JavaScript 24.99% TypeScript 74.38% Makefile 0.11% HTML 0.09% Dockerfile 0.10%

js-algorand-sdk's Introduction

js-algorand-sdk

Build Status npm version

AlgoSDK is the official JavaScript library for communicating with the Algorand network. It's designed for modern browsers and Node.js.

Installation

$ npm install algosdk

This package provides TypeScript types, but you will need TypeScript version 4.2 or higher to use them properly.

For errors in Webpack 5 or Vite projects, you will need to install extra dependencies.

Browser

Include a minified browser bundle directly in your HTML like so:

<script
  src="https://unpkg.com/[email protected]/dist/browser/algosdk.min.js"
  integrity="sha384-SwM9TdxjIFpIT2FUfchrQvtwi748UI0q12Zi32yd6BM8D/lCTumPhw0+BrPC0yd0"
  crossorigin="anonymous"
></script>

or

<script
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/algosdk.min.js"
  integrity="sha384-SwM9TdxjIFpIT2FUfchrQvtwi748UI0q12Zi32yd6BM8D/lCTumPhw0+BrPC0yd0"
  crossorigin="anonymous"
></script>

Information about hosting the package for yourself, finding the browser bundles of previous versions, and computing the SRI hash is available here.

Quick Start

const token = 'Your algod API token';
const server = 'http://127.0.0.1';
const port = 8080;
const client = new algosdk.Algodv2(token, server, port);

(async () => {
  console.log(await client.status().do());
})().catch((e) => {
  console.log(e);
});

Documentation

Documentation for this SDK is available here: https://algorand.github.io/js-algorand-sdk/. Additional resources are available on https://developer.algorand.org.

Examples

Running examples requires access to a running node. Follow the instructions in Algorand's developer resources to install a node on your computer.

As portions of the codebase are written in TypeScript, example files cannot be run directly using node. Please refer to the instructions described in the examples/README.md file for more information regarding running the examples.

SDK Development

Building

To build a new version of the library, run:

npm run build

Generating Documentation

To generate the documentation website, run:

npm run docs

The static website will be located in the docs/ directory.

Testing

We have two test suites: mocha tests in this repo, and the Algorand SDK test suite from https://github.com/algorand/algorand-sdk-testing.

Node.js

To run the mocha tests in Node.js, run:

npm test

To run the SDK test suite in Node.js, run:

make docker-test

Browsers

The test suites can also run in browsers. To do so, set the environment variable TEST_BROWSER to one of our supported browsers. Currently we support testing in chrome and firefox. When TEST_BROWSER is set, the mocha and SDK test suites will run in that browser.

For example, to run mocha tests in Chrome:

TEST_BROWSER=chrome npm test

And to run SDK tests in Firefox:

TEST_BROWSER=firefox make docker-test

Code Style

This project enforces a modified version of the Airbnb code style.

We've setup linters and formatters to help catch errors and improve the development experience:

  • Prettier โ€“ ensures that code is formatted in a readable way.
  • ESLint โ€” checks code for antipatterns as well as formatting.

If using the Visual Studio Code editor with the recommended extensions, ESLint errors should be highlighted in red and the Prettier extension should format code on every save.

Precommit Hook

The linters and formatters listed above should run automatically on each commit to catch errors early and save CI running time.

License

js-algorand-sdk is licensed under an MIT license. See the LICENSE file for details.

js-algorand-sdk's People

Contributors

algorotem avatar algojack avatar jasonpaulos avatar onetechnical avatar evanjrichard avatar barnjamin avatar mjiang102628 avatar jdtzmn avatar algobarb avatar rotemh avatar algorandskiy avatar algochoi avatar egieseke avatar jasonweathersby avatar winder avatar shiqizng avatar vervious avatar algolucky avatar fionnachan avatar algo-devops-service avatar bricerisingalgorand avatar michaeldiamant avatar eric-warehime avatar algoidurovic avatar excalq avatar fgamundi avatar aldur avatar fabrice102 avatar rfustino avatar joe-p 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.