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

@agoric/pixel-demo

v0.0.3

Published

An example non-fungible token and app using ERTP

Downloads

20

Readme

Pixel Demo

This demo is roughly based on Reddit's r/Place, but has a number of additional features that showcase the unique affordances of the Agoric platform, including: higher-order contracts, easy creation of new assets, and safe code reusability.

| Reddit's r/place | |:--:| | Reddit's r/place as a social experiment in cooperation |

Installation

| | |:--:| | The testnet pixel demo. Slightly fewer pixels. |

The pixel demo runs on our private testnet. For instructions on how to run a local, off-chain version for yourself, please see Scenario 3. The testnet documentation also includes a short walkthrough of the demo with sample commands. If you would rather view the code and learn more about how the demo works, feel free to read on.

ERTP: Electronic Rights Transfer Protocol

The pixel demo uses our smart contract framework, called ERTP, or the Electronic Rights Transfer Protocol. Throw away all you know about public key hashes mapped to account balances, because ERTP doesn't use 'em. In fact, ERTP itself doesn't have any concept of cryptography. Instead, it uses object capabilities to enforce access control. Instead of having to prove ownership of a corresponding private key, in the world of object capabilities, if your program has a reference to an object, it can call methods on that object. If it doesn't have a reference, it can't. For more on object capabilities, see Chip Morningstar's post. For more on ERTP, see a quick tutorial and the ERTP interface descriptions for assay.js, unitOps.js and contractHost.js.

A preemption hierarchy of rights

All of the pixels (individual squares) on the demo webpage are owned by the gallery, the code that administrates the pixels. The gallery has the power to revoke the pixels from any user at any time. When a user calls gallery!tapFaucet(), the gallery takes the least recently colored pixel from its current holder (if anyone holds it) and gives it to the user in the form of an ERTP payment.

| The hierarchy of rights in the pixel demo | |:--:| | The preemption hierarchy of rights in the pixel demo |

The gallery is able to revoke the pixels held by users because the pixel demo creates a customized version of ERTP in which rights are hierarchical. Hierarchical rights are familiar in property. For instance, a property owner might lease an apartment to a tenant, who might in turn, lease it to a subtenant. Anyone higher in the hierarchy can take away access from anyone lower in the hierarchy, and give it to someone else.

Using Pixels

ERTP provides a makeMint function that takes in a configuration function. The pixel demo configuration implements the hierarchical rights and allows us to add additional methods to purses and payments.

To be able to color a pixel, the user must first get a "use object" from a purse or payment that contains pixels:

const useObj = E(payment).getUse()

The "use object" that they receive acts just like any other JavaScript object. It has methods (in this case, all associated with coloring the pixels in the underlying purse or payment) that can be called. To color, the user does:

E(useObj).changeColorAll('#000000');

with the hex color of their choice.

Transferring revocable rights

When a user wants to give another user the ability to color a pixel, but wants to be able to revoke that ability later, the user can call claimChild and pass the childPayment to the other user. The other user can tell that they aren't getting a payment on the same level as one that the gallery would give out, and it could be revoked at any point if claimChild() is called again on the original payment.

Buying and selling pixels

The users can buy and sell pixels with the gallery at any time by calling sellToGallery(pixelUnits) and buyFromGallery(pixelUnits). They must pass in a units that describes exactly what they want to sell or buy. If successful, they will get an invitation from the gallery for a simple, secure escrow exchange of the pixels for "dust", the currency that the gallery transacts in. Users do not start out with any dust - they only start out with access to the faucet.

In order to amass the pixels that they want in order to draw their masterpiece, the user will need to sell some pixels to get dust. The gallery will always buy pixels back, but it values pixels near the center much more than pixels on the periphery.