Skip to content

Repository files navigation

rain.datacontract

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/length slicing rather than start/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.

Install

Via soldeer:

forge soldeer install rain-datacontract~<version>

Develop

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 test

Tasks:

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

Use the nix-pinned forge for all development.

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.

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

SSTORE2 inspired implementation of data contracts

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages