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

@gluwa/creditcoin-js

v0.9.5

Published

## Getting started

Downloads

2

Readme

creditcoin-js

Getting started

Preqrequisites

Creditcoin-js requires the following to be installed:

Install

Adding Creditcoin-JS to your project is easy. Install it by using a JavaScript package manager like npm or yarn:

yarn add @gluwa/creditcoin-js

This will install the latest release version, which should allow you to interact with Creditcoin's main network and your own local chains that use the latest Creditcoin binaries.

Usage

Import

Importing the library into your project:

import { creditcoinApi } from '@gluwa/creditcoin-js';

const { api } = await CreditcoinApi('ws://localhost:9944');

Using the API

The API is a collection of modules that provide access to the various functions of the Creditcoin blockchain.

const { api, extrinsics, utils } = await CreditcoinApi('ws://localhost:9944');

Creating transactions

const { api } = await CreditcoinApi('ws://localhost:9944');

const tx = api.
    .tx
    .balances
    .transfer(
        "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
        "1000000000000000"  // CTC amount in microunits
                            // (1 CTC = 1e18 microunits)
    )

Signing & sending

import { Keyring } from '@gluwa/creditcoin-js';

const keyring = new Keyring({ type: 'sr25519' });
// const fromSeed = keyring.addFromUri("bottom drive obey lake curtain smoke basket hold race lonely fit walk");
const alice = keyring.addFromUri('//Alice');

await tx.signAndSend(alice);

Batching transactions

const tx1 = api.tx.balances.transfer(addrBob, 10);
const tx2 = api.tx.balances.transfer(addrCharlie, 10);
const txs = [tx1, tx2];

const batch_tx = api.tx.utility.batch(txs);

await batch_tx.signAndSend(alice);

Development

Build

To build the project, run the following command from the root directory:

yarn build

Updating Type definitions

Creditcoin-JS uses actual chain metadata to generate the API types and augmented endpoints. When the Creditcoin blockchain gets updated and includes new extrinsics or storage fields in it’s pallets, Creditcoin-JS must regenerate its types to include the newly available methods.

  1. Fetch Chain Metadata

This process begins with pulling the current metadata from a running creditcoin-node by making an RPC call. You can use the get-metadata.sh script to do this. It will save the metadata to a file called creditcoin.json.

./get-metadata.sh
  1. Generate Types

The types can be generated by running the following command:

yarn build:types

Errors & Troubleshooting

If after following the build process you run into errors where credicoin-js isn't reflecting the changes in the rust code you may need to clear your cache. The following command (run from root directory) can help:

cd creditcoin-js && rm -rf lib && yarn install && yarn build && yarn pack && cd ../integration-tests/ && yarn cache clean && rm -rf node_modules && yarn upgrade creditcoin-js && yarn install