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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bcode-tech/bcode-sdk

v1.1.1

Published

SDK to integrate Bcode functionalities in any system

Readme

Bcode SDK

Bcode SDK is a set of tool to help developer interact with Bcode API.

Written in Typescript and tested with Jest

Installation

From source code:

npm install git+https://github.com/bcode-tech/bcode-sdk.git

From npm:

npm install --save @bcode-tech/bcode-sdk

Usage

First you need to call the constructor, if you want to generate a new Wallet every time you can implemented like this:

const { BcodeSDK } = require("@bcode-tech/bcode-sdk")

(async () => {

    const sdk = new BcodeSDK({
        apiKey: <your-api-key>,
        config: { env: <environment>, debugMode: true },
    });

    await sdk.init()
})()

Otherwise if you already have a private key that you want to use you can use:

const { BcodeSDK } = require("@bcode-tech/bcode-sdk")

(async () => {

    const sdk = new BcodeSDK({
        apiKey: <your-api-key>,
        privateKey: <private-key>,
        config: { env: <environment>, debugMode: true },
    });

    await sdk.init()
})()

It's possible to change private key later:

const { BcodeSDK } = require("@bcode-tech/bcode-sdk")

(async () => {

    const sdk = new BcodeSDK({
        apiKey: <your-api-key>,
        privateKey: <private-key>,
        config: { env: <environment>, debugMode: true },
    });

    await sdk.init()

    sdk.setPrivateKey("private_key")
})()

Constructor config object parameters:

| Param | Default value | Options | | --------- | ------------- | ------------- | | env | AMOY | AMOY, POLYGON | | debugMode | false | true, false |

Test

For running test you need to create privateKeys.json, with an array of at least 3 privateKeys to submit to test script.

Functions

init()

Initilize user wallet and configure


setPrivateKey()

Set private key after creation, to enable auth logic

Params

| Param | Default value | | ---------- | ------------------ | | privateKey | Wallet private key |


setMnemonicPhrase()

Set mnemonic phrase after creation, to enable auth logic

Params

| Param | Default value | | -------- | ---------------------- | | mnemonic | Wallet mnemonic phrase |


resetWallet()

Reset wallet to null and delete private key


regenerateWallet()

Generate new wallet after creation or after deleting previous one


getAuthToken()

Returns authToken received from Bcode API to authenticate call, it depends on API Key used.


getAPIKey()

Returns apiKey used in contructor, just for reference.


getWalletAddress(address)

Returns address for generated wallet.

getBcodeTokenBalance(address)

Return Bcode Token (PTK) balance of current wallet or the specified address.

Params

| Param | Default value | | ------- | ------------- | | address | user address |


getMaticBalance()

Return MATIC balance of the current wallet or the specidfied address.

Params

| Param | Default value | | ------- | ------------- | | address | user address |


requestToken(amount, contractAddress)

Function for request minting of CustomERC20 token.

| Param | Descriptioon | | --------------- | ------------------------------------- | | amount | Token quantity to mint | | contractAddress | Address of CustomERC20 token contract |


prepareTransaction(contractObj, functionName, params)

Prepare transaction that need to be executed through meta transaction.

| Param | Default value | Description | | ------------ | ----------------------------- | --------------------------------------------- | | contractObj | Array with Bcode NFT Contract | Array of interested contract addresses | | functionName | Current user address | Wallet address of NFT owner | | params | Array | Array of original prams for contract function |

Example:

const tx = await sdk.prepareTransaction(
  {
    address: config[`TEST_META_TX_${env}`],
    abi: testMetaTxAbi,
    name: "TestMetaTransaction",
    version: "0.0.1",
  },
  "increment",
  []
));

executeTransaction(tx, optionals)

Prepare transaction that need to be executed through meta transaction.

| Param | Description | | --------- | ------------------------------------------- | | tx | Array of interested contract addresses | | optionals | Object with webhookUrl, secret and metadata |

Example:

type MetaTransaction = {
  contractAddress: string;
  userAddress: string;
  functionSignature: string;
  r: string;
  s: string;
  v: any;
};

type Optionals = {
  webhookUrl: string | null;
  metadata: { [key: string]: any } | null;
  secret: string | null;
};

async executeTransaction(tx: MetaTransaction, optionals: Optionals | null)

executeAsyncTransaction(tx, optionals)

Prepare transaction that need to be executed through meta transaction in async mode. API return a requestId needed to refetch transaction status later.

| Param | Description | | --------- | ------------------------------------------- | | tx | Array of interested contract addresses | | optionals | Object with webhookUrl, secret and metadata |

Example:

type MetaTransaction = {
  contractAddress: string;
  userAddress: string;
  functionSignature: string;
  r: string;
  s: string;
  v: any;
};

type Optionals = {
  webhookUrl: string | null;
  metadata: { [key: string]: any } | null;
  secret: string | null;
};

async executeAsyncTransaction(tx: MetaTransaction, optionals: Optionals | null)

notarizeHash(hash, optionals)

Request meta transaction notarization, return notarization receipt.

| Param | Description | | --------- | ------------------------------------------- | | hash | Hash of document to notarize | | optionals | Object with webhookUrl, secret and metadata |

Example:

type Optionals = {
  webhookUrl: string | null;
  metadata: { [key: string]: any } | null;
  secret: string | null;
};

async notarizeHash(hash: string, optionals: Optionals | null)

mintBcodeNFT(amount, uri, contractAddress, webhookUrl)

Function for request mint of an NFT.

| Param | Default value | Description | | -------------- | ------------------ | --------------------------------------------------- | | amount | none | Amount of NFT to mint | | uri | none | URI of NFT resources | | contractAddres | Bcode NFT Contract | Address of CustomNFT contract | | webhookUrl | null | URL of webhook endpoint on which receive a response |


sendBcodeNFT(to, tokenId, deadline, contractAddress)

Function for send NFT. It has a built-in permit request to allow Bcode to transfer NFT for user wallet.

| Param | Default value | Description | | --------------- | ------------------ | ----------------------------- | | to | none | Receiver of NFT | | tokenId | none | TokenID of NFT to transfer | | contractAddress | Bcode NFT Contract | Address of CustomNFT contract |


getOwnedNFT(contractAddresses, ownerAddress)

Function that returns all NFT for the passes contract addresses for the given owner address.

| Param | Default value | Description | | ----------------- | ----------------------------- | -------------------------------------- | | contractAddresses | Array with Bcode NFT Contract | Array of interested contract addresses | | ownerAddress | Current user address | Wallet address of NFT owner |


checkJWTValidity()

Function that check if fetched JWT is still valid


getAPIVersion()

Returns Bcode API service version, just to check if the service is available

Utility

Inside the BcodeSDK we had embed a set of tools to handle critic logic easily.

Hash

Hash allow the devloper to generate BcodeAPI compatible hash with SHA256 algorithm.

import { Hash } from "bcode-sdk";

const hash = Hash.fromString("try-me");

const imageHash = Hash.fromBuffer(Buffer.from("try-me"));

QRCode

BcodeSDK has integrate QRCode library, to easy generate QRCode of string.

import { QRCode } from "bcode-sdk";

QRCode.fromString("try-me").print();

QRCode.fromString("try-me").buffer();

Made with ❤️ by Bcode