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

transient-lib

v1.2.0

Published

## Installation

Readme

Library for custom transient storage types

Installation

Install with:

npm i transient-lib

Hardhat tests: set target to "cancun" both in compiler block and evm block in hardhat.config.js:

  solidity: {
    version: "0.8.24",
    settings: {
      evmVersion: "cancun",
    },
  },
  networks: {
    hardhat: {
      hardfork: "cancun"
    },
  }

Import to contract and declare transient variables as storage variables. They do not use storage, but act like a syntax sugar for holding the slot number

pragma solidity ^0.8.24;

import "transient-lib/contracts/libs/TransientVariables.sol";

contract ReentrancyProtection {
    using TransientVariables for *;

    TransientVariables.Bool isReentrant;

    modifier noReentrant {
        require (isReentrant.get() == false, "Reentrancy is not allowed");
        reentransyFlag.set(true);
    }
}

TransientVariables.sol

At this moment this library supports 4 static types:

TransientVariables.Uint256 for transient uint256
TransientVariables.Address for transient address
TransientVariables.Bytes32 for transient bytes32
TransientVariables.Bool for transient boolean

Use them via setters and getters

variable.set(value);
value = variable.get;

TransientArrays.sol

Only arrays of the abovementioned static types are supported:

TransientArrays.ArrayUint256 for array of uint256
TransientArrays.ArrayAddress for array of address
TransientArrays.ArrayBytes32 for array of bytes32
TransientArrays.ArrayBool for array of boolean

They are accessed by the following methods:

arr.length() // Returns the length of the array
arr.set(index, value); // Sets value on index. Reverts on out-of-bounds
value = arr.get(index); // Gets value by index. Reverts on out-of-bounds
arr.push(value);  // Pushes a new value to the end of the array
arr.pop(); // Pops the last value from the end of the array. Reverts on empty array
arraytype[] memory arr1 = arr.toMemory(); // Writes array to memory

TransientMappings.sol

Currentrly only 3 types of mappings are implemented:

TransientMappings.MappingAddressToUint256 for mapping(address => uint256)
TransientMappings.MappingAddressToBytes32 for mapping(address => bytes32)
TransientMappings.MappingBytes32ToBool for mapping(bytes32 => bool)

They are accessed by the following methods:

map.set(key, value); // Sets value on key.
value = map.get(key); // Gets value by key.

Since it is very lengthy to define mapping for each pair of static types, one should take them as example and implement your own mapping type.

At first you need to define your custom type. It is just a syntax sugar and a placeholder for a slot:

    struct MappingBytes32ToUint256 {
        uint256 dummy;
    }

The most tricky part is converting your custom type to abstract mapping type, since all the methods you need are incapsulated in this abstract type. You should define the function that converts your type into the abstract Mapping type from TransientMaster.sol lib

    function convertMyCustomTypeToMapping(
        MappingBytes32ToUint256 storage v
    ) private pure returns(TransientMaster.Mapping storage r) {
        assembly {
            r.slot := v.slot
        }
    }

Then just use abstract Mapping methods to define setter and getter:

    function set(
        MappingBytes32ToUint256 storage self,
        bytes32 key,
        uint256 value
    ) internal {
        TransientMaster.Mapping storage m = convertMyCustomTypeToMapping(self);
        TransientMaster.Variable storage v = m.getVariable(key);
        v.setUint256(value);
    }

    function get(
        MappingBytes32ToUint256 storage self,
        bytes32 key
    ) internal view returns (uint256 value) {
        TransientMaster.Mapping storage m = convertMyCustomTypeToMapping(self);
        TransientMaster.Variable storage v = m.getVariable(key);
        value = v.getUint256();
    }