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

cnft-spam-filter

v1.1.2

Published

a set of useful utils for determining if a cNFT on solana is spam or not

Downloads

46

Readme

cnft-spam-filter

An open-source, lightweight, and portable spam classifier for cNFTs on Solana.

Can run anywhere that webassembly runs: on a server, in a lambda function, and even running entirely in your browser.

Also included is the model training code and data, so you can train and bring your own model if the default model is not performing well.

Feature extraction is done with a combination of on-chain data and OCR using the tesseract.js library. Classification is done with naive bayes and a hand-picked set of spam and ham cNFTs.

Live Example

You can try a live (slow + heavily rate limited) example of the library running on AWS Lambda here:

https://api.filtoor.xyz/classify?address=A1xhLVywcq6SeZnmRG1pUzoSWxVMpS6J5ShEbt3smQJr

Try a new cNFT by replacing the address={...} parameter. The classifier will either spit out "spam" or "ham" (or "error" if something went wrong).

If you'd like to use this API in your production project, please DM me to get set up!

Installation

First, install the library:

npm i cnft-spam-filter

then import the requisite function:

const { extractAndClassify } = require("cnft-spam-filter")

or

import { extractAndClassify } from "cnft-spam-filter"

Finally, call the function wherever you want to classify:

const classification = await extractAndClassify(assetId, rpcUrl);

Note that you'll need to bring your own rpcUrl that supports the DAS api--I recommend Helius for their generous free plan https://www.helius.dev/.

Examples

You can find a few lightweight examples of how to use the library in different environments in the /examples folder of the repository.

cnft-spam-filter aims to be portable, so you can run it in pretty much any environment that you want.

Training

You can train your own model and pass it to classify(tokens, model). Code for this is in the /train folder.

You'll see spam_ids.json and ham_ids.json there; these are the cNFTs used to train the model.

Testing

You can test the accuracy of a model using the code in the /test folder. Make sure that your training set and test set do not overlap.

Usage in Production

If you want to use cnft-spam-filter in production, we recommend setting up a caching layer so that you don't have to analyze each cNFT multiple times. This should be done at your own app level: you can use redis, a database, localstorage--whatever you want.

Contributing

Feel free to open pull requests to contribute if you think this is interesting! I will try to get to them as best as I can. There are definitely some tasks that need to be implemented.

License

All code is released under the MIT license -- go crazy.

Solana asset donations are appreciated but not required by any means:

filtoor.sol