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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gotchipus/sdk

v1.0.1

Published

Official SDK for building Gotchipus Hooks - interfaces, base contracts, and utilities

Readme

@gotchipus/sdk

Official SDK for building Gotchipus Hooks - interfaces, base contracts, and utilities.

npm version License: MIT

Installation

# npm
npm install @gotchipus/sdk

# yarn
yarn add @gotchipus/sdk

# pnpm
pnpm add @gotchipus/sdk

# Foundry
forge install gotchipus/sdk

Quick Start

Option 1: Implement IHook Interface (Minimal)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import { IHook } from "@gotchipus/sdk/contracts/interfaces/IHook.sol";

contract MyHook is IHook {
    bytes4 private constant HOOK_SUCCESS = 0x378e142e;

    function getHookPermissions() external pure override returns (Permissions memory) {
        return Permissions({ beforeExecute: true, afterExecute: false });
    }

    function beforeExecute(HookParams calldata params) external override returns (bytes4) {
        // Your custom logic here
        require(params.value < 1 ether, "Value too high");
        return HOOK_SUCCESS;
    }

    function afterExecute(HookParams calldata) external pure override returns (bytes4) {
        revert("Not implemented");
    }
}

Option 2: Extend BaseHook (Recommended)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;

import { BeforeExecuteHook } from "@gotchipus/sdk/contracts/base/BaseHook.sol";
import { IHook } from "@gotchipus/sdk/contracts/interfaces/IHook.sol";

contract MyHook is BeforeExecuteHook {
    constructor(address _gotchipus) BeforeExecuteHook(_gotchipus) {}

    function _beforeExecute(IHook.HookParams calldata params) internal view override {
        // Your custom logic here
        require(params.value < 1 ether, "Value too high");
        // No need to return - BaseHook handles it
    }
}

Available Contracts

Interfaces

| Contract | Description | |----------|-------------| | IHook | Core interface that all hooks must implement |

Base Contracts

| Contract | Description | |----------|-------------| | BaseHook | Abstract base with safety checks | | BeforeExecuteHook | For hooks that only run before execution | | AfterExecuteHook | For hooks that only run after execution | | FullHook | For hooks that run before and after execution |

Libraries

| Contract | Description | |----------|-------------| | HookConstants | Common constants (HOOK_SUCCESS, etc.) | | HookErrors | Custom error definitions |

Hook Types

BeforeExecuteHook

Runs before the account executes a transaction. Use cases:

  • Access control / whitelisting
  • Spending limits
  • Transaction validation
  • Rate limiting
contract WhitelistHook is BeforeExecuteHook {
    mapping(address => bool) public whitelist;

    constructor(address _gotchipus) BeforeExecuteHook(_gotchipus) {}

    function _beforeExecute(IHook.HookParams calldata params) internal view override {
        require(whitelist[params.to], "Target not whitelisted");
    }
}

AfterExecuteHook

Runs after the account executes a transaction. Use cases:

  • Reward distribution
  • Event logging
  • State updates based on results
contract RewardHook is AfterExecuteHook {
    constructor(address _gotchipus) AfterExecuteHook(_gotchipus) {}

    function _afterExecute(IHook.HookParams calldata params) internal override {
        if (params.success) {
            // Distribute rewards
        }
    }
}

FullHook

Runs both before and after execution. Use cases:

  • Comprehensive logging
  • Complex state management
  • Gas metering
contract LoggerHook is FullHook {
    constructor(address _gotchipus) FullHook(_gotchipus) {}

    function _beforeExecute(IHook.HookParams calldata params) internal override {
        emit ExecutionStarted(params.tokenId, params.to);
    }

    function _afterExecute(IHook.HookParams calldata params) internal override {
        emit ExecutionCompleted(params.tokenId, params.success);
    }
}

HookParams Reference

struct HookParams {
    uint256 tokenId;    // Gotchipus NFT token ID
    address account;    // ERC6551 token-bound account
    address caller;     // Transaction initiator
    address to;         // Target contract/address
    uint256 value;      // ETH value
    bytes4 selector;    // Function selector
    bytes hookData;     // Full calldata
    bool success;       // Execution result (afterExecute only)
    bytes returnData;   // Return data (afterExecute only)
}

Foundry Setup

Add to remappings.txt:

@gotchipus/sdk/=node_modules/@gotchipus/sdk/

Or install via forge:

forge install gotchipus/sdk

Then add remapping:

@gotchipus/sdk/=lib/sdk/

Hardhat Setup

Works out of the box with npm imports:

import "@gotchipus/sdk/contracts/interfaces/IHook.sol";

Security Considerations

  1. Always validate permissions - Ensure your hook's getHookPermissions() matches implemented functions
  2. Use onlyGotchipus modifier - BaseHook includes this; implement it if using IHook directly
  3. Handle failures gracefully - Consider what happens if your hook reverts
  4. Gas limits - Be mindful of gas consumption in hooks

Examples

See the examples directory for complete hook implementations:

  • WhitelistHook - Address whitelisting
  • SpendingLimitHook - Daily spending limits
  • RewardDistributorHook - Post-execution rewards
  • ExecutionLoggerHook - Comprehensive logging

Contributing

Contributions are welcome! Please read our Contributing Guide first.

License

MIT License - see LICENSE for details.

Links