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

@ak48/starcoin

v1.5.3-ak48

Published

starcoin js sdk

Downloads

3

Readme

Starcoin SDK

starcoin.js is a full featured sdk for developing dapp on Starcoin blockchain network.

Type Architecture Diagram

Docs

Starcoin Javascript SDK

Usage

First, start a Starcoin node with websocket and http APIs opened.

./starcoin -n dev --miner-thread 4 --websocket-apis all --http-apis all

or

./starcoin -n barnard --miner-thread 4 --websocket-apis all --http-apis all
let provider = new JsonRpcProvider("http://localhost:9850");

/// Get txn data.
const txnData = await provider.getTransaction(txnHash);
const txnInfoData = await provider.getTransactionInfo(txnHash);

/// Send Transaction

let signer = provider.getSigner();
await signer.unlock(""); // put password into the quotes
// starcoin node should enable account jsonrpc api.
const txnRequest = {
    script: {
      code: '0x1::TransferScripts::peer_to_peer',
      type_args: ['0x1::STC::STC'],
      args: ['0xc13b50bdb12e3fdd03c4e3b05e34926a', 'x"29b6012aee31a216af67c3d05e21a092c13b50bdb12e3fdd03c4e3b05e34926a"', '100000u128'],
    }
};
let txn = await signer.sendTransaction(txnRequest);
// wait for 7 confirmations.
const txnInfo = await txn.wait(7);
console.log(txnInfo);

Utils

Decode Events

TransactionEvents returned from node are encoded in BCS format. client sdk should decode the data to see the detailed information.

import encoding from 'starcoin';
import 'starcoin';

let provider = new JsonRpcProvider("http://localhost:9850");

// Get txn info.
const txnEvents = await provider.getEventsOfTransaction(txnHash);
// get a txn event.
const txnEvent = txnEvents.pop();
// then decode with pre-determined event type in onchain_event_types.
console.log(encoding.bcsDecode(DepositEvent, txnEvent.data).toJS());

You can also see the spec in src/index.spec.ts.

Develop

> cd <project>
> yarn
> yarn dev

Publish to npm

  1. change version in package.json

  2. npm run build

  3. npm login

  4. npm config set registry https://registry.npmjs.org/ # use npm config ls to confirm

  5. npm publish --access public --tag latest --dry-run # test locally before actually publishing to the registry

  6. npm publish --access public --tag latest

Welcome for your PRs!