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

@virtoshi/api

v1.0.1

Published

Simulate transactions witht the Virtoshi API

Downloads

3

Readme

@virtoshi/api

A TypeScript package for simulating Partially Signed Bitcoin Transactions (PSBT) and view the state changes that would occur on-chain. This package supports Bitcoin, Ordinals and BRC-20 transfers.

Installation

npm install @virtoshi/api

Usage

const { VirtoshiClient } = require('@virtoshi/api');

const client = new VirtoshiClient({
  apiKey: 'your-api-token',
});

const simulationRequest = {
      psbt: 'cHNidP8BAJ4CAAAAAu2BaIBuhpYKY8ax31ZAVZze1iismPwTPStICuMyUJtGAAAAAAD/////IGFcnPZXzaCe4qr069+JnaAVUGID33eQ4aTpIM0eipEAAAAAAP////8C09/1BQAAAAAZdqkU0MWZA8W6woaHYOkP1SGkZlqnZSCIrADh9QUAAAAAF6kUNUXm4zuDLEcFDyTT7rk8nAOUi8eHsy4TAAABAP1zAQEAAAAAAQIWVufpLOU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DFhMWM3ZjIzNjc5OTc5ODA2NGQxOTM2NDgxYjc5ZjE5YzgxYTdjMDU0N2M2Y2NlN2FmOTRmM2MwYTZpMCIgYWx0PSJuZWNrbGFjZSI+PGltTHRnIHNyYz0iL2NvbnRlbnQvYmViMjFhNmNmNmUxYWNiMDcxMDNhN2I0Mjc2MTkzMWM2NjNmN2RhMjVjOTExNDAxMzQ0NzU4Y2I2NDExNmNjZWkwIiBhbHQ9ImhhdCI+PC9kaXY+CjwvYm9keT48L2h0bWw+CmghwDOf60xmhrkvoLzyCaGst9OMQDAOpvY0ML0RavaqDipuAAAAAAAAAA==',
      addresses: [
        '1L2tGENeoh4mSoiUZrSbs1J3jazSdJH9QS',
        'bc1p9ctdfwx0m20h7spf088erur5um3ule6tff7uqzfhy0xq7vaqwh6sjfs3a5',
      ],
    };

try {
  const simulationResult = await client.simulateTransaction(req);
  // Do something with the simulation result.
  console.log(simulationResponse);
} catch (err) {
  // An error occurred.
  console.log(err)
}

Types

ClientParams

  • endpoint?: string: The API endpoint for the simulation service.
  • apiKey: string: The API token for authentication.

SimulationRequest

  • psbt: string: The hex representation of the partially signed Bitcoin transaction.
  • addresses?: string[]: Optional array of addresses indicating which addresses belong to you, allowing the service to return an aggregated result.

SimulationResponse

  • state_changes: StateChanges: Detailed state changes for each address.
  • aggregated: Aggregated: Aggregated state changes.
  • inputs: number: Value of satoshis of the inputs in the PSBT.
  • outputs: number: Value of satoshis in the PSBT.
  • fee: number: Transaction fee in satoshis for the PSBT.

Aggregated

  • state_change: AggregatedStateChange: Aggregated state changes.

AggregatedStateChange

  • balance: Balance[]: Aggregated balance changes.
  • nft: NFT[]: Aggregated NFT changes.

StateChanges

  • { [address: string]: StateChange }: Object mapping addresses to their respective state changes.

StateChange

  • balance: Balance[]: Array of balance changes.
  • nft: NFT[]: Array of NFT changes.

Balance

  • ticker: string: The currency ticker (e.g., 'BTC').
  • value: number: The balance value in sats.
  • sign: string: The sign indicating whether the balance is positive or negative.

NFT

  • id: string: The unique identifier of the NFT.
  • sign: string: The sign indicating whether the NFT is present or absent.

Contributing

Feel free to contribute by opening issues or creating pull requests. Your feedback and contributions are highly appreciated.

License

This project is licensed under the MIT License - see the LICENSE file for details.