23.12.29 • Published 5 months ago

nexajs v23.12.29

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

NexaJS

https://nexajs.org

NexaJS Banner

A pure JavaScript Library and Software Development Kit (SDK) for building decentralized applications (dApps) powered by the Nexa blockchain.

Released under the terms of the MIT LICENSE.

Documentation

Our docs are updated regularly.

https://docs.nexajs.org

Table of contents

Quick Start

To quickly get started using Nexa in your existing Webapp, simply include this tag in the section of your HTML:

Web2 (CDN) Installation

<!-- CDN (Web2) integration solution -->
<script src="https://cdn.nexajs.org/nexa.min.js"
  integrity="sha384-qBLa2DVAThYbLO3kajnReZVS5cG3m3swWmBL0tNN7CxvzgRZQw/cfwsmbXOGma7K"
  crossorigin="anonymous"></script>

Web3 (IPFS) Installation

<!-- IPFS Gateway (Web3) integration solution -->
<script src="https://bafybeifohi5njjlohhkwcsola3346cn3ngyaqyl5bwn5k7a4mbvtzy4y3m.ipfs.dweb.link/"
  integrity="sha384-qBLa2DVAThYbLO3kajnReZVS5cG3m3swWmBL0tNN7CxvzgRZQw/cfwsmbXOGma7K"
  crossorigin="anonymous"></script>

Web4 (CAPD | Nostr) Installation

<!-- Counterparty and Protocol Discovery (Web4) integration solution -->
<script src="proto://9addf9bc724b2e14094950598918dde63b091253e6106b7d9716nexaverse888"></script>

Package Manager Installation

npm install --save nexajs
yarn add nexajs
pnpm install nexajs

WARNING: We presently don't provide any tooling to verify that the release on npm matches GitHub. As such, you should verify anything downloaded by npm against your own verified copy.

Introduction

The NexaJS Library + SDK aims to be a modern & comprehensive toolkit for creating decentralized applications (dApps) on the Nexa Blockchain and its expansive Web3 ecosystem.

Prerequisites

  • Node v12+

Requirements

  • Basic JavaScript knowledge

Installation

npm install nexajs

Building the Workspace

Install your preferred Integrated Development Environment (IDE) or text editor, eg:

  • Visual Studio Code (VSC)
  • Atom
  • Sublime

Example file: send-tx.js

import Nexa from 'nexajs'

const privateKey = new Nexa.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy')

const utxo = {
    txId        : '115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986',
    outputIndex : 0,
    address     : '17XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV',
    script      : '76a91447862fe165e6121af80d5dde1ecb478ed170565b88ac',
    satoshis    : 50000,
}

const transaction = new Nexa.Transaction()
    .from(utxo)
    .to('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000)
    .sign(privateKey)

From the terminal / command-line:

$ node examples/send-tx.js

Should I use this in Production?

If you are thinking of using the master branch of this library in production, stop. Master is not stable; it is our development branch, and only tagged releases may be classified as stable.

Can I trust this Code?

Don't trust. Verify.

We recommend every user of this library and the nexajs ecosystem audit and verify any underlying code for its validity and suitability, including reviewing any and all of your project's dependencies.

Mistakes and bugs happen, but with your help in resolving and reporting issues, together we can produce open source software that is:

  • Easy to audit and verify,
  • Tested, with test coverage >95%,
  • Advanced and feature rich,
  • Standardized, using prettier and Node Buffer's throughout, and
  • Friendly, with a strong and helpful community, ready to answer questions.

Usage

Crypto is hard.

When working with private keys, the random number generator is fundamentally one of the most important parts of any software you write. For random number generation, we default to the randombytes module, which uses window.crypto.getRandomValues in the browser, or Node js' crypto.randomBytes, depending on your build system. Although this default is ~OK, there is no simple way to detect if the underlying RNG provided is good enough, or if it is catastrophically bad. You should always verify this yourself to your own standards.

Finally, adhere to best practice. We are not an authorative source of best practice, but, at the very least:

Browser

The recommended method of using nexajs-lib in your browser is through Browserify. If you're familiar with how to use browserify, ignore this and carry on, otherwise, it is recommended to read the tutorial at https://browserify.org/.

NOTE: We use Node Maintenance LTS features, if you need strict ES5, use --transform babelify in conjunction with your browserify step (using an es2015 preset).

WARNING: iOS devices have problems, use at least buffer@5.0.5 or greater, and enforce the test suites (for Buffer, and any other dependency) pass before use.

Examples

The below examples are implemented as integration tests, they should be very easy to understand. Otherwise, pull requests are appreciated. Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP).

If you have a use case that you feel could be listed here, please ask for it!

Packages List

The following suite of 26 packages compose the entire NexaJS Library and Software Development Kit (SDK).

  • NOTE: Not all packages are published to the NPM registry.

Contributing

See CONTRIBUTING.md.

Running the Test Suite

npm test
npm run-script coverage

Similar Libraries

23.12.29

5 months ago

23.12.26

5 months ago

23.12.25

5 months ago

23.12.13

5 months ago

23.12.5

6 months ago

23.11.2

7 months ago

23.11.8

6 months ago

23.11.14

6 months ago

23.11.13

6 months ago

23.11.11

6 months ago

23.10.19

7 months ago

23.10.18

7 months ago

23.10.16

7 months ago

23.10.15

7 months ago

23.10.14

7 months ago

23.10.13

7 months ago

23.10.12

7 months ago

23.10.11

7 months ago

23.10.8

7 months ago

23.10.9

7 months ago

23.10.7

8 months ago

23.10.25

7 months ago

23.10.24

7 months ago

23.10.23

7 months ago

23.10.22

7 months ago

23.10.21

7 months ago

23.10.20

7 months ago

23.9.5

9 months ago

23.9.4

9 months ago

23.8.21

9 months ago

23.8.20

9 months ago

23.8.9

9 months ago

23.8.18

9 months ago

23.7.25

10 months ago

23.8.12

9 months ago

23.8.11

9 months ago

23.8.30

9 months ago

23.4.12

1 year ago

23.4.13

1 year ago

23.3.1

1 year ago

23.4.6

1 year ago

23.3.10

1 year ago

23.3.7

1 year ago

23.4.5

1 year ago

23.3.11

1 year ago

23.3.18

1 year ago

23.2.28

1 year ago

23.3.17

1 year ago

23.2.27

1 year ago

23.3.19

1 year ago

23.3.9

1 year ago

23.3.8

1 year ago

22.12.23

1 year ago