Gathering detailed insights and metrics for ethereum-bloom-filters
Gathering detailed insights and metrics for ethereum-bloom-filters
Gathering detailed insights and metrics for ethereum-bloom-filters
Gathering detailed insights and metrics for ethereum-bloom-filters
npm install ethereum-bloom-filters
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
87 Stars
80 Commits
8 Forks
2 Watching
1 Branches
1 Contributors
Updated on 28 Aug 2024
TypeScript (93.16%)
JavaScript (6.84%)
Cumulative downloads
Total Downloads
Last day
4.4%
89,303
Compared to previous day
Last week
7.6%
487,298
Compared to previous week
Last month
8.7%
1,948,930
Compared to previous month
Last year
-10%
21,204,253
Compared to previous year
1
A lightweight bloom filter client which allows you to test ethereum blooms for fast checks of set membership.
This package only has 1 dependency which is on @noble/hashes
which has no dependencies on at all and is funded by ethereum foundation.
1$ npm install ethereum-bloom-filters
1$ yarn add ethereum-bloom-filters
1var ethereumBloomFilters = require('ethereum-bloom-filters');
1const ethereumBloomFilters = require('ethereum-bloom-filters');
1import { 2 isBloom, 3 isUserEthereumAddressInBloom, 4 isContractAddressInBloom, 5 isTopic, 6 isTopicInBloom, 7 isInBloom, 8} from 'ethereum-bloom-filters';
When using angular, react or vuejs these frameworks handle dependencies and transpile them so they work on the web, so if you're using any of them just use the above code snippets to start using this package.
If you're using a standard web application you can go here to copy any of the versioned script files and then dropping it into your web application, making sure you reference it within a script tag in the head of the website.
This will expose the library as a global variable named ethereumBloomFilters
, you can then execute the methods through this variable:
1ethereumBloomFilters.isBloom(...) 2ethereumBloomFilters.isUserEthereumAddressInBloom(...) 3ethereumBloomFilters.isContractAddressInBloom(...) 4ethereumBloomFilters.isTopic(...) 5ethereumBloomFilters.isTopicInBloom(...) 6ethereumBloomFilters.isInBloom(...)
You can find out more about the functions parameters below.
We do not expose an cdn for security reasons.
A Bloom filter is a probabilistic, space-efficient data structure used for fast checks of set membership. That probably doesn’t mean much to you yet, and so let’s explore how bloom filters might be used.
Imagine that we have some large set of data, and we want to be able to quickly test if some element is currently in that set. The naive way of checking might be to query the set to see if our element is in there. That’s probably fine if our data set is relatively small. Unfortunately, if our data set is really big, this search might take a while. Luckily, we have tricks to speed things up in the ethereum world!
A bloom filter is one of these tricks. The basic idea behind the Bloom filter is to hash each new element that goes into the data set, take certain bits from this hash, and then use those bits to fill in parts of a fixed-size bit array (e.g. set certain bits to 1). This bit array is called a bloom filter.
Later, when we want to check if an element is in the set, we simply hash the element and check that the right bits are in the bloom filter. If at least one of the bits is 0, then the element definitely isn’t in our data set! If all of the bits are 1, then the element might be in the data set, but we need to actually query the database to be sure. So we might have false positives, but we’ll never have false negatives. This can greatly reduce the number of database queries we have to make.
A ethereum real life example in where this is useful is if you want to update a users balance on every new block so it stays as close to real time as possible. Without using a bloom filter on every new block you would have to force the balances even if that user may not of had any activity within that block. But if you use the logBlooms from the block you can test the bloom filter against the users ethereum address before you do any more slow operations, this will dramatically decrease the amount of calls you do as you will only be doing those extra operations if that ethereum address is within that block (minus the false positives outcome which will be negligible). This will be highly performant for your app.
Blooms do not work with eth transactions (purely sending eth), eth transactions do not emit logs so do not exist in the bloom filter. This is what ethereum did purposely but it means you should query the eth balance every block to make sure it's in sync. Blooms will only work if the transaction emits an event which then ends up in the logs. The bloom filter is there to help you find logs. A contract can be written which does not emit an event and in that case, would not be queryable from a bloom filter. The erc20 token spec requires you to fire an event on approval
and transfer
so blooms will work for approval
and transfer
for ALL erc20 tokens, this will be most people's primary use-case. Saying that this can be used in any way you want with any use-case as long as events are emitted then it's queryable.
1isBloom(bloom: string): boolean;
Returns true if the bloom is a valid bloom.
1isUserEthereumAddressInBloom(bloom: string, ethereumAddress: string): boolean;
Returns true if the ethereum users address is part of the given bloom note: false positives are possible.
1isContractAddressInBloom(bloom: string, contractAddress: string): boolean;
Returns true if the contract address is part of the given bloom note: false positives are possible.
1isTopic(topic: string): boolean;
Returns true if the topic is valid
1isTopicInBloom(bloom: string, topic: string): boolean;
Returns true if the topic is part of the given bloom note: false positives are possible.
This is the raw base method which the other bloom methods above use. You can pass in a bloom and a value which will return true if its part of the given bloom.
1isInBloom(bloom: string, value: string | Uint8Array): boolean;
Returns true if the value is part of the given bloom note: false positives are possible.
Please raise any issues in the below link.
https://github.com/joshstevens19/ethereum-bloom-filters/issues
To run locally firstly run:
1$ npm install
To build:
1$ tsc
To watch build:
1$ tsc --watch
To run tests:
1$ npm test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morebloom-filters
JS implementation of probabilistic data structures: Bloom Filter (and its derived), HyperLogLog, Count-Min Sketch, Top-K and MinHash
pixi-filters
[![Node.js CI](https://github.com/pixijs/filters/workflows/Node.js%20CI/badge.svg)](https://github.com/pixijs/filters/actions/workflows/nodejs.yml?query=branch%3Amain) [![npm version](https://badge.fury.io/js/pixi-filters.svg)](https://www.npmjs.com/packa
@redis/bloom
This package provides support for the [RedisBloom](https://redisbloom.io) module, which adds additional probabilistic data structures to Redis. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the R
tldts-experimental
Library to work against complex domain names, subdomains and URIs.