Skip to content

rainlanguage/rain.solmem

Repository files navigation

rain.solmem

Solidity memory libraries — pointer arithmetic, byte-level copying, and dynamic arrays/matrices that don't go through Solidity's safety-checked allocator.

Libraries

Library What it does
LibPointer Raw memory pointer arithmetic, with explicit Pointer user-defined type.
LibMemCpy Word-aligned and byte-aligned memcpy between memory pointers.
LibBytes In-place mutation, slicing, and pointer-level access for bytes.
LibUint256Array Dynamic uint256[] operations: extend, copy, dedup-sort, truncate.
LibBytes32Array Dynamic bytes32[] mirror of LibUint256Array.
LibUint256Matrix uint256[][] operations.
LibBytes32Matrix bytes32[][] operations.
LibStackPointer Stack-style push/pop on a memory region accessed via Pointer.
LibStackSentinel Sentinel-terminated stack walks for unknown-length data.

These libraries assume the caller knows what they're doing with memory. Out-of- bounds access, double-frees, and aliasing are the caller's responsibility.

Install

Via soldeer (in your foundry project's root):

forge soldeer install rain-solmem~<version>

Versioned remappings end up in dependencies/rain-solmem-<version>/. Add the remapping to remappings.txt or foundry.toml.

Develop

This repo uses nix for its dev shell. The default shell is the slim Solidity-only sol-shell from rainix — no rust, node, or chromium.

nix develop          # enter the shell
forge soldeer install # install dependencies declared in foundry.toml
forge test

Tasks exposed via the shell (delegate to rainix):

  • rainix-sol-testforge test
  • rainix-sol-static — slither
  • rainix-sol-legalreuse lint
  • rainix-sol-artifactsforge build

Use the nix-pinned forge for all development to keep versions consistent.

Publish

Tag v<x.y.z> on main. The Publish to Soldeer workflow runs forge soldeer push rain-solmem~<x.y.z> on every v* tag. The package name is derived from the repo name with . substituted for -.

License

DecentraLicense 1.0 (DCL-1.0) — full text in LICENSES/. Roughly CAL-1.0 (opensource.org) plus user-data disclosure obligations consistent with permissionless-blockchain assumptions. "Not your keys, not your coins" aware, in legalese.

This repo is REUSE 3.2 compliant. Verify locally:

nix develop -c rainix-sol-legal

Contributions

Welcome under the same license. Contributors warrant that their contributions are compliant.

About

Solidity lib for working with bytes in memory

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors