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

@boostxyz/signatures

v1.1.0

Published

An offline database of builtin bytes4 selectors and their corresponding abi items

Downloads

427

Readme

Boost Known Signatures

A registry of known function and event signatures, their 32 byte selectors, and AbiEvents or AbiFunctions

How to use this package

When you're creating a Boost and building out action steps for use with the Event Actions, you'll need to specify the function or event's signature so the protocol knows how to validate that an action has occured in a transaction, and allow a claim to occur.

In order to simplify applications that would otherwise need to know the hex encoded 4 byte function selector, or 32 byte event selector, and their associated ABI items, you can instead use this library to save on code and complexity.

// you can import both events and functions registries
import { events, functions } from '@boostxyz/signatures'
// ...or individually
import events from '@boostxyz/signatures/events'
import functions from '@boostxyz/signatures/functions'

// both events and functions manifests have the following interface:
type eventsOrFunctionsRegistry = { abi: Record<(Hex | string), AbiItem>, selectors: Record<string, Hex> }
// where string keys are the signature ie: Transfer(address indexed,address indexed,uint256 indexed)

// the event signature we'll be using to compose the action
const knownSignature = "Transfer(address indexed,address indexed,uint256 indexed)"
const selector = events.selectors[knownSignature] // 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
const abiItem = events.abi[knownSignature] // {name:"Transfer",type:"event",inputs:[{type:"address",indexed:true},{type:"address",indexed:true},{type:"uint256",indexed:true}]}

// now you have everything you need to construct your event action
const filterOnReceiver: ActionStep = {
  chainid: 8453,
  signature: selector,
  signatureType: SignatureType.EVENT, // We're working with an event
  targetContract: targetContract, // Address of the contract emitting the `Transfer` event
  // We want to target the 'receiver' property on the Transfer event
  actionParameter: {
    filterType: FilterType.EQUAL, // Filter to check for equality
    fieldType: PrimitiveType.ADDRESS, // The field we're filtering is an address
    fieldIndex: 1, // We want to target the second argument (index 1) of the event signature
    filterData: '0xc0ffee', // Filtering based on the recipient's address
  },
};

If you've used a function or event signature from @boostxyz/signatures in the creation of your Boost, then you don't have to do anything else for validation to work.

Otherwise, if you're supplying a custom event signature unknown to @boostxyz/signatures and running your own validation using the SDK, you'll need to additionally supply your own AbiEvent to validation so event logs can be correctly pulled off transactions.

await boostCore.validateActionSteps({
    knownEvents: {
        '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef': {
            name: "Transfer",
            type: "event",
            inputs: [
                { type: "address", indexed: true },
                { type: "address", indexed: true },
                { type: "uint256", indexed: true }
            ]
        }
    }
})

For more detailed examples, see sample use cases

Contributing new signatures

To integrate your contracts with the Boost V2 Protocol:

The Boost Protocol team will review the submission and promptly release a new version of the @boostxyz/signatures package so you can continue your Boost Protocol integrations.