ERC4337 Data Libs
Getting Started

Getting started

SentinelList

SentinelList is a Solidity library that can be installed in different ways. Below, you will find instructions for using it together with Foundry.

Installation

Using a package manager

npm i https://github.com/rhinestonewtf/sentinellist

Using git submodules

forge install rhinestonewtf/sentinellist

Quick Start

In a contract, you can use the SentinelList library to store a linked list of addresses:

import {SentinelListLib} from "sentinellist/SentinelList.sol";
 
contract Example {
    using SentinelListLib for SentinelListLib.SentinelList;
 
    // Declare a variable to store the data
    // Note: this can also be in a mapping or other data structure
    SentinelListLib.SentinelList list;
 
    function set(address newAddress) external {
        // Store the data
        list.push(newAddress);
    }
 
    function get(uint256 size) external view returns (address[] memory addressArray) {
        // Retrieve the data
        (addressArray,) = list.getEntriesPaginated(SENTINEL, size);
    }
}

FlatBytes

FlatBytes is a Solidity library that can be installed in different ways. Below, you will find instructions for using it together with Foundry.

Installation

Using a package manager

npm i https://github.com/rhinestonewtf/flatbytes

Using git submodules

forge install rhinestonewtf/flatbytes

Quick Start

In a contract, you can use the FlatBytes library to store bytes in a way that is compliant with the ERC-4337 standard:

import { FlatBytesLib } from "flatbytes/BytesLib.sol";
 
contract Example {
    using FlatBytesLib for FlatBytesLib.Bytes;
 
    // Declare a variable to store the data
    // Note: this can also be in a mapping or other data structure
    FlatBytesLib.Bytes data;
 
    function set(bytes memory _data) external {
        // Store the data
        data.store(_data);
    }
 
    function get() external view returns (bytes memory) {
        // Retrieve the data
        return data.load();
    }
}