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

@matterpool/superasset-js

v1.1.4

Published

SuperAsset Javascript SDK - matterpool.io

Downloads

34

Readme

SuperAsset Javascript Library

Standard Bitcoin Smart Contracts for Assets. SuperAsset Whitepaper https://matterpool.io

SuperAsset is a collection of Standard Bitcoin Smart Contract Templates.

header

What's Included

SimpleAsset10 (SA10)

Non-Fungible-Token (NFT) Smart Contract for Bitcoin. Used for any digital property, license, media, or state tracking.

Features:

  • Mint, transfer, update, and melt tokens that retain their identity and satoshi balance until melted.
  • Supports seperate funding inputs and change outputs with ANYONECANPAY
  • Store arbitrary data payloads (HTML, JSON, Protobuf, PDFs, images, XML, etc)
  • Infuse satoshis to be locked into the asset for life cycle
  • Replay protection with globally unique ID passed on as an 'identity baton'
  • Can destroy the token via "melt" and retrieve the satoshis
  • Identical trust guarantees for the authenticity of this asset as a plain UTXO
  • Users can trivially verify authenticity and title history by requesting it in it's entirety from the seller
  • Wallets and indexers can proactively index these UTXO's via a blind pattern match for the minting pattern (see below)
  • Simplfied Payment Verification (SPV) and 0-conf works as expected with all the properties afforded to the native satoshi
Contract Code and State Layout:
//  ==========================================================================
//                       |
//    SA10 STATIC CODE   | OP_RETURN tokenID(36B) ownerPublicKey(33B) [ payload(varlen) ]
//                       |
//  ==========================================================================

SimpleAsset20 (SA20)

Fungible-Token (FT) Smart Contract for Bitcoin. Useful for creating entire classes of related data with an initial supply that can be transferred just like regular p2pkh UTXOs.

Coming soon...


Install

npm install superasset-js

Preview

// Import the library or include it in a <script/> tag
import * as simpleasset from 'simpleasset';
var simpleasset = require('simpleasset');
const sa10 = superasset.instance({
    feeb: 0.5,
}).SA10({ verbose: true });

// Set up the keys used below.
const privateKey1= new bsv.PrivateKey('wifkey1');
const publicKey1 = bsv.PublicKey.fromPrivateKey(privateKey1)

const privateKey2 = new bsv.PrivateKey('wifkey2')
const publicKey2 = bsv.PublicKey.fromPrivateKey(privateKey2)

// -----------------------------------------------------
// DEPLOYMENT
//
// Deploy NFT with initial owner and satoshis value of 7000 (Lower than this may hit dust limit)
// Example: https://whatsonchain.com/tx/1bb01a6660b4f6b1cbb60ff141eea61052950fe75957026b79f7f62941d6e998
const assetValue = 20000;
const initialOwnerPublicKey = publicKey1.toString();
const fundingPrivateKey = privateKey2.toString();
let assetState = await sa10.deploy(initialOwnerPublicKey, assetValue, fundingPrivateKey);

// -----------------------------------------------------
// TRANSFER (AND UPDATE) - JSON Example
//
// Note: The payload data must follow minimal push encoding rules.
// Reference: https://github.com/moneybutton/bsv/blob/bsv-legacy/lib/script/script.js#L1083
// Client can send NFT to a public key and keep funding input and change seperate
// Example: https://whatsonchain.com/tx/cc97616a873c002abc42f03a51ed5611a89ac1cc619c8d3e343fd09a3bf2cb94
let payloadUpdate = Buffer.from(`{ "hello": "world" }`, 'utf8').toString('hex');
let currentOwnerPrivateKey = privateKey1.toString();
let nextOwnerPublicKey = publicKey2.toString();
assetState = await sa10.transfer(assetState, currentOwnerPrivateKey, nextOwnerPublicKey, fundingPrivateKey, payloadUpdate);

// -----------------------------------------------------
// TRANSFER (AND UPDATE) - HEX Binary Data Example
//
// Note: The payload data must follow minimal push encoding rules.
// Reference: https://github.com/moneybutton/bsv/blob/bsv-legacy/lib/script/script.js#L1083
// Client can send NFT to a public key and keep funding input and change seperate
// Example: https://whatsonchain.com/tx/23ff92f9026160a0f84ac578ac6bf2c0bfe516a8471523c12eb8f4a88a7a55d7
payloadUpdate = '012345';
currentOwnerPrivateKey = privateKey2.toString();
nextOwnerPublicKey = publicKey2.toString();
assetState = await sa10.transfer(assetState, currentOwnerPrivateKey, nextOwnerPublicKey, fundingPrivateKey, payloadUpdate);

// -----------------------------------------------------
// TRANSFER (AND UPDATE) - Empty/null Payload example
//
// Note: The payload data must follow minimal push encoding rules.
// Reference: https://github.com/moneybutton/bsv/blob/bsv-legacy/lib/script/script.js#L1083
// Client can send NFT to a public key and keep funding input and change seperate
// Example: https://whatsonchain.com/tx/b2d5283b70414581188296cbf360f4a9ff089cd1fd6a9b3227964f76001cc5f8
payloadUpdate = '';
currentOwnerPrivateKey = privateKey2.toString();
nextOwnerPublicKey = publicKey2.toString();
assetState = await sa10.transfer(assetState, currentOwnerPrivateKey, nextOwnerPublicKey, fundingPrivateKey, payloadUpdate);

// -----------------------------------------------------
// MELT
//
// Melt back to regular p2pkh satoshis
// Client can send back NFT value to another address and keep change seperate
// Example: https://whatsonchain.com/tx/ae44aaa9aad8433b74d1f6d9dedf57deb47ab3b9e671549bdd36b0ca9f8e9567
payloadUpdate = null;
currentOwnerPrivateKey = privateKey2.toString();
let receiverPublicKey = publicKey2.toString();
assetState = await sa10.melt(assetState, currentOwnerPrivateKey, receiverPublicKey, fundingPrivateKey);

Build and Test

npm install
npm run build
npm run test

Any questions or ideas?

@mxtterpool

https://matterpool.io