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

psffpp

v1.1.9

Published

PS010 PSF File Pinning Protocol

Downloads

27

Readme

psffpp

PSFFPP = Permissionless Software Foundation File Pinning Protocol.

This is an npm library for node.js. It implements the PS010 specification for the PSF File Pinning Protocol. The main consumers of this library is:

Instancing Library

This library depends on the minimal-slp-wallet and psf-multisig-approval libraries. An instance of minimal-slp-wallet is expected to be injected into this library when it is instantiated. Here is an example:

import SlpWallet from 'minimal-slp-wallet'
import PSFFPP from 'psffpp'

async function start() {
  // Instance the BCH wallet
  const wallet = new SlpWallet(undefined, {
    interface: 'consumer-api',
    restURL: 'https://free-bch.fullstack.cash'
  })
  await wallet.initialize()

  // Instance this library
  const psffpp = new PSFFPP({wallet})
}
start()

Get the Write Price

Retrieve the current cost-per-megabyte in PSF tokens, for writing data to the network.

Note: The minimum cost is 1MB, even if you upload a file smaller than that to the file pinning network.

const writePrice = await psffpp.getMcWritePrice()
console.log(writePrice)

/*
  0.08335233
*/

Create a Pin Claim

Files are pinned in a two-step process:

  1. Upload the file to the IPFS network, which returns a CID.
  2. A Pin Claim is generated on the BCH blockchain using the IPFS CID.

Generating a Pin Claim is also a two-step process:

  1. Calculate the cost of pinning the file (in PSF tokens), then burn that amount to generate a Proof-of-Burn (proof of payment). This is a transaction on the blockchain. and is returned as pobTxid.
  2. Generate a Pin Claim transaction that includes the pobTxid, the CID, and the filename. This is a second transaction on the blockchain, and is returned as claimTxid.

A Pin Claim can be generated with this library:

const pinObj = {
  cid: 'bafkreih7eeixbkyvabqdde4g5mdourjidxpsgf6bgz6f7ouxqr24stg6f4',
  filename: 'test.txt',
  fileSizeInMegabytes: 0.1
}

const {pobTxid, claimTxid} = await psffpp.createPinClaim(pinObj)
console.log('pobTxid: ', pobTxid)
console.log('claimTxid: ', claimTxid)

/*
pobTxid: f1ff81aaac7f755875306e31c9137b2bb010587feffeb4c7d42b462ef08db0df
claimTxid: db338fdb7edc6ce6685c9897a9d9fd6f0e26d194bf12e1c87470b7dc2103a3e3
*/

License

MIT