Simplified reimplementation of sstore2:
write arbitrary bytes (up to 65534 bytes) into a deployable contract and read
it back.
Differences from sstore2:
- No internal ABI-encoding allocations.
- Optimised for the 1:1 data-to-contract case.
- Assembly hot path for less gas.
- No unrelated code shipped — single library.
- Fuzzed with foundry.
- Reverts on out-of-range slices instead of silently truncating.
start/lengthslicing rather thanstart/end.- Writes require cancun (MCOPY) on the executing chain; reads do not.
Output is creation code deployable by any mechanism that works for
type(Foo).creationCode — direct create, Zoltu deterministic proxy, etc. (a
minimal 13-byte loader prefix plus the data — not solc output, so no constructor
logic or metadata). Deployment is left to the caller, and so is the target
chain's code size limit: the library only enforces its own encoding limit of
65534 data bytes, so on EIP-170 chains (24576 runtime bytes) at most 24575 data
bytes are deployable.
Two read functions: read returns the entire deployed bytes; readSlice
returns a start/length slice.
Via soldeer:
forge soldeer install rain-datacontract~<version>This repo uses nix. The default shell is the
slim sol-shell from rainix.
nix develop # enter the shell
forge soldeer install # install deps declared in foundry.toml
forge testTasks:
rainix-sol-test—forge testrainix-sol-static— slitherrainix-sol-legal—reuse lint
Use the nix-pinned forge for all development.
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.
This repo is REUSE 3.2 compliant. Verify locally:
nix develop -c rainix-sol-legalWelcome under the same license. Contributors warrant that their contributions are compliant.