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

btms-core

v0.2.26

Published

Tools for creating and managing UTXO-based tokens

Downloads

75

Readme

btms-core

Tools for creating and managing UTXO-based tokens

Installation

npm i btms-core

Example Usage

// todo

Documentation

Links: API, Interfaces, Classes

Interfaces

| | | --- | | Asset | | IncomingPayment | | OverlaySearchResult | | OwnershipProof | | SubmitResult | | TokenForRecipient |

Links: API, Interfaces, Classes


Interface: Asset

export interface Asset {
    assetId: string;
    balance: number;
    name?: string;
    iconURL?: string;
    metadata?: string;
    incoming?: boolean;
    incomingAmount?: number;
    new?: boolean;
}

Links: API, Interfaces, Classes


Interface: TokenForRecipient

export interface TokenForRecipient {
    txid: string;
    vout: number;
    amount: number;
    envelope: CreateActionResult;
    keyID: string;
    outputScript: string;
}

Links: API, Interfaces, Classes


Interface: SubmitResult

export interface SubmitResult {
    status: "auccess";
    topics: Record<string, number[]>;
}

Links: API, Interfaces, Classes


Interface: OverlaySearchResult

export interface OverlaySearchResult {
    inputs: string | null;
    mapiResponses: string | null;
    outputScript: string;
    proof: string | null;
    rawTx: string;
    satoshis: number;
    txid: string;
    vout: number;
}

Links: API, Interfaces, Classes


Interface: IncomingPayment

export interface IncomingPayment {
    txid: string;
    vout: number;
    outputScript: string;
    amount: number;
    token: TokenForRecipient;
    sender: string;
    messageId: string;
    keyID: string;
    envelope: CreateActionResult;
}

Links: API, Interfaces, Classes


Interface: OwnershipProof

export interface OwnershipProof {
    prover: string;
    verifier: string;
    assetId: string;
    amount: number;
    tokens: {
        output: GetTransactionOutputResult;
        linkage: SpecificKeyLinkageResult;
    }[];
}

Links: API, Interfaces, Classes


Classes

Class: BTMS

The BTMS class provides an interface for managing and transacting assets using the Babbage SDK.

export class BTMS {
    confederacyHost: string;
    peerServHost: string;
    tokenator: Tokenator;
    tokensMessageBox: string;
    marketplaceMessageBox: string;
    protocolID: string;
    basket: string;
    tokenTopic: string;
    satoshis: number;
    authrite: Authrite;
    privateKey: string | undefined;
    marketplaceTopic: string;
    constructor(confederacyHost = "https://confederacy.babbage.systems", peerServHost = "https://peerserv.babbage.systems", tokensMessageBox = "tokens-box", protocolID = "tokens", basket = "tokens", tokensTopic = "tokens", satoshis = 1000, privateKey?: string, marketplaceMessageBox = "marketplace", marketplaceTopic = "marketplace") 
    async listAssets(): Promise<Asset[]> 
    async issue(amount: number, name: string): Promise<SubmitResult> 
    async send(assetId: string, recipient: string, sendAmount: number, disablePeerServ = false, onPaymentSent = (payment: TokenForRecipient) => { }): Promise<SubmitResult> 
    async listIncomingPayments(assetId: string): Promise<IncomingPayment[]> 
    async acceptIncomingPayment(assetId: string, payment: IncomingPayment): Promise<boolean> 
    async refundIncomingTransaction(assetId: string, payment: IncomingPayment): Promise<SubmitResult> 
    async getTokens(assetId: string, includeEnvelope = true): Promise<GetTransactionOutputResult[]> 
    async getBalance(assetId: string, myTokens?: GetTransactionOutputResult[]): Promise<number> 
    async getTransactions(assetId: string, limit: number, offset: number): Promise<{
        transactions: {
            date: string;
            amount: number;
            txid: string;
            counterparty: string;
        }[];
    }> 
    async proveOwnership(assetId: string, amount: number, verifier: string): Promise<OwnershipProof> 
    async verifyOwnership(proof: OwnershipProof, useAnyoneKey = false): Promise<boolean> 
    validateAssetId(assetId: string): boolean 
    async listAssetForSale(assetId: string, amount: number, desiredAssets: Record<string, number>, description?: string): Promise<SubmitResult> 
    async findAllAssetsForSale(findMine = false): Promise<MarketplaceEntry[]> 
    async makeOffer(entry: MarketplaceEntry, assetId: string, amount: number): Promise<void> 
    async listOutgoingOffers(): Promise<MarketplaceOffer[]> 
    async cancelOutgoingOffer(offer: MarketplaceOffer): Promise<void> 
    async listIncomingOffers(forEntry?: MarketplaceEntry): Promise<MarketplaceOffer[]> 
    async acceptOffer(offer: MarketplaceOffer): Promise<void> 
    async acknowledgeNewlyAcquiredMarketplaceAssets(): Promise<void> 
    async rejectOffer(offer: MarketplaceOffer): Promise<void> 
    async acknowledgeRejection(offer: MarketplaceOffer): Promise<void> 
}
Constructor

BTMS constructor.

constructor(confederacyHost = "https://confederacy.babbage.systems", peerServHost = "https://peerserv.babbage.systems", tokensMessageBox = "tokens-box", protocolID = "tokens", basket = "tokens", tokensTopic = "tokens", satoshis = 1000, privateKey?: string, marketplaceMessageBox = "marketplace", marketplaceTopic = "marketplace") 

Argument Details

  • confederacyHost
    • The confederacy host URL.
  • peerServHost
    • The peer service host URL.
  • tokensMessageBox
    • The message box ID.
  • protocolID
    • The protocol ID.
  • basket
    • The asset basket ID.
  • tokensTopic
    • The topic associated with the asset.
  • satoshis
    • The number of satoshis involved in transactions.
Method findAllAssetsForSale

Returns an array of all marketplace entries

async findAllAssetsForSale(findMine = false): Promise<MarketplaceEntry[]> 

Returns

An array of all marketplace entries

Method getBalance

Get the balance of a given asset.

async getBalance(assetId: string, myTokens?: GetTransactionOutputResult[]): Promise<number> 

Returns

Returns a promise that resolves to the balance.

Argument Details

  • assetId
    • The ID of the asset.
  • myTokens
    • (Optional) An array of token objects owned by the caller.
Method getTokens

Get all tokens for a given asset.

async getTokens(assetId: string, includeEnvelope = true): Promise<GetTransactionOutputResult[]> 

Returns

Returns a promise that resolves to an array of token objects.

Argument Details

  • assetId
    • The ID of the asset.
  • includeEnvelope
    • Include the envelope in the result.
Method listAssetForSale

Lists an asset on the marketplace for sale

async listAssetForSale(assetId: string, amount: number, desiredAssets: Record<string, number>, description?: string): Promise<SubmitResult> 

Returns

Overlay network submission results

Argument Details

  • assetId
    • The ID of the asset to list
  • amount
    • The amount you want to sell
  • desiredAssets
    • Assets you would desire to have in return so people can make you an offer
  • description
    • Marketplace listing description
Method listIncomingPayments

List incoming payments for a given asset.

async listIncomingPayments(assetId: string): Promise<IncomingPayment[]> 

Returns

Returns a promise that resolves to an array of payment objects.

Argument Details

  • assetId
    • The ID of the asset.
Method send

Send tokens to a recipient.

async send(assetId: string, recipient: string, sendAmount: number, disablePeerServ = false, onPaymentSent = (payment: TokenForRecipient) => { }): Promise<SubmitResult> 

Returns

Returns a promise that resolves to a transaction action object.

Argument Details

  • assetId
    • The ID of the asset to be sent.
  • recipient
    • The recipient's public key.
  • sendAmount
    • The amount of the asset to be sent.

Throws

Throws an error if the sender does not have enough tokens.

Method validateAssetId

Checks that an asset ID is in the correct format

validateAssetId(assetId: string): boolean 

Returns

a boolean indicating asset ID validity

Argument Details

  • assetId
    • Asset ID to validate

Links: API, Interfaces, Classes


License

The license for the code in this repository is the Open BSV License.