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

@beetapp/beet-js

v0.6.1

Published

Beet-js is the client lib for Beet, a stand-alone key-manager and signing app for BitShares.

Downloads

13

Readme

BeetJS

BeetJS is the client library for interaction with Beet (https://github.com/bitshares/beet).

Installation

Node module

npm install @beetapp/beet-js

Browserify

The browser bundle is built using webpack and can be found in

dist/beet-js.js

Examples

Examples to try and play around can be found in examples folder. Basically there are two options, library injection and direct calls.

Library injection

Powerful and easy way to integrate Beet is by using injection. Not supported for all chains yet.

List of supported blockchains:

  • BitShares
  • Steem, WhaleShares and Smoke
  • BinanceChain

Generic In this example, SYMBOL is the core token of the blockchain you want to interact with (e.g. BTS with the BitShares Blockchain) and someBlockchainLibrary needs to be filled with the library you want to use.

<script src="beet-js.js"></script>
<script src="some-blockchain-library.js"></script>

<script>
    let init = async function() {
        try {
            // link to beet
            let app = await beet.get("Binance Transfer Example", "SYMBOL");
            console.log("Linked account", app.SYMBOL.getAccount());
  
            const someBlockchainLibrary = ... // load your blockchain library
            let beetifiedLibrary = app.BNB_TEST.inject(someBlockchainLibrary);
            
            // use like beetifiedLibrary just as if its the normal library, every signature and broadcast request is redirected to Beet
        } catch (err) {
            console.error(err);
        }
    };
    init();
</script>

Steem

<script src="beet-js.js"></script>
<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>

<script>
    let init = async function() {
        try {
            // link to beet
            let app = await beet.get("Library Injection: Example", "STEEM");
            console.log("Linked account", app.STEEM.getAccount());

            // inject beet
            const beetifiedSteem = app.STEEM.inject(steem);

            beetifiedSteem.broadcast.customJson(
                "inject_wif",  // will be replaced with actual private key in Beet
                [account.name],
                [],
                "beet",
                JSON.stringify([
                    "broadcast-example",
                    {
                        text: "This custom json data was put on Steem with Beet",
                        url: "https://github.com/bitshares/beet"
                    }
                ]),
                (err, result) => {
                    console.log("injectedCall", err, result);
                }
            );
        } catch (err) {
            console.error(err);
        }
    };
    init();
</script>

Direct Calls

Beet supports direct calls which are implemented for each chain. Currently that is transfer, vote, signMessage and verifyMessage.

vote

Not available for every chain.

Steem

<script src="beet-js.js"></script>

<script>
    let init = async function() {
        try {
            let app = await beet.get("Direct Call: Transfer", "STEEM");
            console.log("Linked account", app.STEEM.getAccount());
            await app.STEEM.voteFor(
                {
                    author: "clockwork",
                    permlink: "beet-the-bitshares-companion",
                    weight: 1
                }
            );
        } catch (err) {
            console.error(err);
        }
    };
    init();
</script>

BitShares

<script src="dist/beet-js.js"></script>

<script>
    let init = async function() {
        try {
            let app = await beet.get("BitShares Vote Example", "BTS");
            await app.BTS.voteFor({id: "1.6.117"});  // witness clockwork
        } catch (err) {
            console.error(err);
        }
    };
    init();
</script>

transfer

BinanceChain (Testnet) Async

<script src="beet-js.js"></script>

<script>
    let init = async function() {
        try {
            let app = await beet.get("Direct Call: Transfer", "BNB_TEST");
            console.log("Linked account", app.BNB_TEST.getAccount());
            await app.BNB_TEST.transfer(
                {
                    to: "tbnb1ems4j20fq6e24pjmqht7le78uteqp6nftexxn2",
                    amount:
                        {
                            satoshis: 10000,
                            asset_id: "BNB"
                        }
                }
            );
        } catch (err) {
            console.error(err);
        }
    };
    init();
</script>

signMessage

EOSIO Mainnet Promisified

<script src="beet-js.js"></script>

<script>
beet.get("Direct Call: Signed Message", "EOS").then(beet => {
    beet.EOS.signMessage("This is a message to be signed!").then(res => {
        console.log(res);
    }).catch((err) => {
        console.error(err);
    });
}).catch((err) => {
    console.error(err);
});
</script>