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

@abstractfruitfactory/radix-js

v1.1.10

Published

This library is intended for use specifically within the Radix Desktop Wallet, not for general use. It is undocumented, unsupported, and may be changed at any time. Use at your own risk. We have disabled issues, although PRs with bug fixes will be consid

Downloads

2,552

Readme

This library is intended for use specifically within the Radix Desktop Wallet, not for general use. It is undocumented, unsupported, and may be changed at any time. Use at your own risk. We have disabled issues, although PRs with bug fixes will be considered.

For the Olympia mainnet release, no language-specific libraries are offered and we instead recommend use of the simple JSON RPC and REST API endpoints offered by the Radix node. These cover the full token and staking functionality of Olympia, sufficient for exchange or wallet integration.

The later Alexandria and Babylon releases will focus more on developer functionality and so heavily refactored APIs and new libraries are expected to start to be introduced at that time. We expect these new APIs and libraries to become the primary method of programmatic interaction with the Radix network at its Babylon release.

Build and run tests

yarn build && yarn bootstrap
yarn test

Publish a new release

When new changes have been merged into the main branch, and you want to publish a new version, make sure you're up to date with main branch locally and do:

yarn release

It will automatically bump the versions in the changed packages, update the changelog, commit and publish to npm.

For commits to main branch, please follow Conventional Commits.

Usage

WORK IN PROGRESS

Creating a new Radix instance

import { Radix, Wallet } from 'radixdlt-javascript` 

const walletResult = Wallet.new('parrot try blind immune drink stay three cluster ship draw fluid become despair primary curtain')

if (walletResult.isErr()) throw walletResult.error

const wallet = walletResult.value

const radix = Radix.new(wallet)
await radix.connect('http://localhost:8080')

or, in a style that maps the result:

import { Radix, Wallet } from 'radixdlt-javascript` 

const result =
  Wallet.new('parrot try blind immune drink stay three cluster ship draw fluid become despair primary curtain')
  .map(
    wallet => Radix.new(wallet)
  )

if (result.isErr()) throw result.error

const radix = result.value
await radix.connect('http://localhost:8080')

Saving a keystore

await wallet.saveKeystore('path/to/keystore')

Creating a Radix instance from a saved keystore:

import { Radix, Wallet } from 'radixdlt-javascript`
import fs from 'fs'

const keystore = fs.readFileSync('path/to/keystore/keystore.json')

const result =
  Wallet.fromKeystore(keystore)
  .map(
    wallet => Radix.new(wallet)
  )

if (result.isErr()) throw result.error

const radix = result.value

Managing accounts

let activeAccount

activeAccount = await radix.activeAccountPromise() // account at index 0
await radix.deriveNextAccount()
activeAccount = await radix.activeAccountPromise() // account at index 1

await radix.switchAccount(0)

activeAccount = await radix.activeAccountPromise() // account at index 0

Subscribing to data stream:

const sub = radix.activeAccount.subscribe(account => console.log(account))

sub.unsubscribe() // stop polling

Interacting with the network

Getting token balances

As a continuous data stream:

const sub = radix.tokenBalances.subscribe(
   result => { // invoked every second
      if (result.isErr()) // handle error

      const balances = result.value
   }
)

sub.unsubscribe() // stops polling

as a one-off response:

const result = await radix.tokenBalancesPromise()

if (result.isErr()) throw result.error

const balances = result.value

Getting a validator

const result = await radix.lookupValidator('rv1qvz3anvawgvm7pwvjs7xmjg48dvndczkgnufh475k2tqa2vm5c6cq4mrz0p')

if (result.isErr()) throw result.error

const validator = result.value

Sending tokens

const { status, completion } = radix.transferTokens(
  'rdx1qsps28kdn4epn0c9ej2rcmwfz5a4jdhq2ez03x7h6jefvr4fnwnrtqqjaj7dt', // recipient address
  10, // amount
  'xrd_rb1qya85pwq' // token identifier,
  {
    plaintext: 'this is a message!',
    encrypted: false
  },
  confirm => {
    // waiting for confirmation before continuing
    confirm()
  }
)

status.subscribe(status => console.log(event))

const result = await completion

if (result.isErr()) // handle error

const txID = result.value