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

algosdk-fetch

v2.7.0

Published

The official JavaScript SDK for Algorand

Downloads

10

Readme

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

Node.js

$ 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-MBUb3pc2VI86j87sLfTwm1kEs2PUDCOFXnXdgspn0lWSJOxr1gu4mZL6L7VE1ITH"
  crossorigin="anonymous"
></script>

or

<script
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/browser/algosdk.min.js"
  integrity="sha384-MBUb3pc2VI86j87sLfTwm1kEs2PUDCOFXnXdgspn0lWSJOxr1gu4mZL6L7VE1ITH"
  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.