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

@punk.bid/sdk

v0.0.3

Published

SDK to interact with the punk.bid contract

Downloads

5

Readme

punk.bid

A bid on punk.bid can target any number of punks, which poses a problem since blockchain storage is expensive and storing thousands of punk ids for each bid on-chain is not economically viable.

this package exposes a Cart class which records the steps taken to fill a bidder's cart. It is then possible to serialize/deserialize those steps in a compact data format and compute the cart's content.

There are 2 kinds of steps:

  • id step to add/remove a punk
  • filter step to add/remove by filter

A filter can specify up to:

  • one type (Alien, Female, etc...)
  • one number of attributes (1 attribute, 5 attributes, etc...)
  • one skin color (Olive skin, Albino skin, etc...)
  • one attribute of each category (see metadata.ts for more info)

Installation

npm install @punk.bid/sdk

Usage

for a complete example, see https://github.com/punkbid/punkbid-sample

import { Cart, filter } from "@punk.bid/sdk";

const cart = new Cart();

// add punk #8
cart.add(8);

// add punk #1 and #10
cart.add([1, 10]);

// typescript offer strong typing & autocomplete on filter traits
// add all punks with only 1 attribute: a purple cap
cart.add(filter(["1 Attribute", "Purple Cap"]));

// remove all Aliens
cart.remove(filter("Alien"));

// retrieve punk ids included in the cart
const punkIds = cart.computeContent();

// serialize the cart in a compact data format
// this metadata is used as input when entering a new bid
const cartMetadata = cart.serialize();

Binary Format of a cart

ve: version (8bits)
--
in: instruction (1 bit): 0=remove, 1=add
st: step type (1bit): 0=filter, 1=id
--
id: punk id (14bits)
--
ty: type (3bits)
sc: skin color (3bits)
ac: number of attribute (4bits)
ha: hair & headgear (6bits)
ey: eyes & eyewear (5bits)
ch: cheeks (2bits)
fa: facial hair (4bits)
mo: mouth (3bits)
ma: mouth accessories (4bits)
ne: neck (2bits)
cl: clown nose (1bit)
ea: earring (1bit)

Format of a serialized cart:

+----+----------------+
| ve | array of steps |
| 8  |  var. length   |
+----+----------------+

Format of an id step (2 bytes):

+----+----+----+
| st | in | id |
| 1  | 1  | 14 |
+----+----+----+

Format of a filter step (5 bytes):

+----+----+----+----+----+----+----+----+----+----+-----+----+----+----+
| st | in | ty | sc | ac | ma | ha | ch | ey | mo | fa  | ne | cl | ea |
| 1  | 1  | 3  | 3  | 4  | 4  | 6  | 2  | 5  | 3  | 4   | 2  | 1  | 1  |
|-------------------+---------+---------+---------+--------------------|
|      1 byte       | 1 byte  | 1 byte  | 1 byte  |       1 byte       |
+----+----+----+----+----+----+----+----+----+----+-----+----+----+----+