Skip to content
Verified contractExactMIT

Marfa1989TemplateStore

Address0xd8be9f8651f4521831dfd762601a42e26dbedc35
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.37

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.37+commit.f401782d
Language
solidity
Optimization
Yes, 30,000 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,246,261
Creation transaction
0xda067cd888…135c71a119

1989/Marfa1989TemplateStore.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.37;
import {Marfa1989ChunkStore} from "./Marfa1989ChunkStore.sol";

/// @notice Immutable, ordered manifest of data chunks whose concatenation hashes to `digest`.
/// Chunk addresses live in inert code rather than storage. No owner, setters or delegatecalls.
contract Marfa1989TemplateStore {
    address private immutable index;
    uint256 private immutable count;
    uint256 public immutable length;
    bytes32 public immutable digest;
    constructor(address[] memory entries,bytes32 expectedDigest) {
        require(entries.length>0 && entries.length<=64,"chunk count");
        uint256 n;
        for(uint256 i;i<entries.length;i++){
            uint256 size=entries[i].code.length;
            require(size>1 && size<=24576,"chunk code");n+=size-1;
        }
        index=address(new Marfa1989ChunkStore(abi.encode(entries)));
        count=entries.length;length=n;digest=expectedDigest;
        require(keccak256(read())==expectedDigest,"template integrity");
    }
    function parts() public view returns(address[] memory entries) {
        uint256 n=count;address source=index;entries=new address[](n);
        // STOP + ABI offset + array length precede the validated address words.
        assembly("memory-safe"){extcodecopy(source,add(entries,32),65,mul(n,32))}
    }
    function read() public view returns(bytes memory data) {
        data=new bytes(length);address[] memory entries=parts();
        // Copy the immutable manifest without checked index/offset arithmetic
        // on every chunk. Bounds remain explicit, including changed/missing code.
        assembly("memory-safe") {
            let dst := add(data,32)
            let end := add(dst,mload(data))
            let at := add(entries,32)
            let partsEnd := add(at,mul(mload(entries),32))
            for {} lt(at,partsEnd) { at := add(at,32) } {
                let part := mload(at)
                let size := extcodesize(part)
                if iszero(size) { revert(0,0) }
                let n := sub(size,1)
                if gt(n,sub(end,dst)) { revert(0,0) }
                extcodecopy(part,dst,1,n)
                dst := add(dst,n)
            }
            if iszero(eq(dst,end)) { revert(0,0) }
        }
    }
}

1989/Marfa1989ChunkStore.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.37;

/// @notice Inert data contract: its runtime code is one STOP byte followed by `data`.
contract Marfa1989ChunkStore {
    constructor(bytes memory data) {
        require(data.length>0 && data.length<=24575,"chunk size");
        bytes memory code=abi.encodePacked(hex"00",data);
        assembly ("memory-safe") {return(add(code,32),mload(code))}
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 30000,
    "enabled": true
  },
  "evmVersion": "cancun"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.