Skip to content
Verified contractExactMIT

Manifest

Address0xee905bd4fa80b3d6508106a49dc400604185df45
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,975,333
Creation transaction
0x62f11d2aed…002b29ef32

paperstock/Manifest.sol

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

//   P A P E R S T O C K
//   ══════════════════════════════════════════════════════════════════════════
//   web      paperstock.fun
//   ──────────────────────────────────────────────────────────────────────────
//   Manifest.sol · THE CARGO
//   2 of 6 · the only contract in the suite whose entire job is to lie, and
//   the only one that tells you so in its own source
//   ══════════════════════════════════════════════════════════════════════════
//
//
//   WHAT IS THIS FOR?
//
//       Every tally the Exchequer cuts is a claim against a lot, and a lot has
//       to be a lot of SOMETHING or the whole thing is an abstraction with a
//       number on it. This contract is where the something comes from.
//
//       Give it a lot number and it gives you a cargo: a commodity, a port of
//       lading, a quantity, a unit of measure, a grade, and a lot mark. Every
//       field is read out of keccak256 of the lot number. There is no input,
//       no oracle, no owner, no stored string and nothing to set.
//
//   ARE THE GOODS REAL?
//
//       No. Not one crate of it. There is no tin, there is no rum, there is no
//       ship and there is no port agent.
//
//       The commodities and the ports are chosen from the manifests of the
//       nineteenth-century bonded trade, and they are deliberately plausible:
//       hemp out of Macassar, cochineal out of Vera Cruz, quicksilver out of
//       Callao. These were ordinary cargoes. A lot line out of this contract
//       reads exactly like a lot line off a real warrant, and that is the
//       joke, and the joke is the product.
//
//       A tokenised-real-world-asset is a string in a database and a PDF you
//       are not shown. This is a string in a pure function and a source file
//       that opens by telling you the cargo does not exist. One of the two is
//       being straight with you about what you are holding.
//
//   THEN WHAT AM I ACTUALLY BUYING?
//
//       Ether. See Exchequer.sol. The cargo is the name on the claim; the
//       backing is the money the Pyx has actually put behind it, and you can
//       read that number at any second of the tally's life. Nothing in this
//       file touches the money and nothing in this file can move it.
//
//   WHY IS IT A SEPARATE CONTRACT?
//
//       Because it holds nothing and can do nothing, and separating it says so
//       more loudly than a comment could. No state, no ether, no writer, no
//       wiring step, no constructor arguments. Every function is pure. Two
//       calls with the same lot number a decade apart return the same cargo,
//       and there is no privileged address anywhere that could arrange
//       otherwise.
//
//   WHAT COULD MAKE THIS WORTHLESS?
//
//       It is already worthless, in the strict sense, and that is the design.
//       This contract adds no value to a tally and removes none. Burn it out of
//       the suite and every claim would be worth the same ether to the wei; you
//       would simply be holding lot 7 instead of
//
//           6,937 hogsheads of gum arabic, Archangel, merchantable quality  [B-351]
//
//       which is what {line} returns for 7, today and in a hundred years. That
//       string is checked against this comment by sim_paper.js on every run —
//       an earlier draft of this header quoted a cargo for lot 7 that the
//       function does not produce, which is a small lie and was found by
//       somebody porting the algorithm to JavaScript and comparing.
//
//       The real risk it carries is a human one. Somebody will screenshot a
//       lot line, crop off the part where it says the cargo is invented, and
//       post it as a holding. Nothing in Solidity can prevent that. The
//       defence is that the admission is in the source, on the website, in the
//       deployment document, and in this paragraph.
//
contract Manifest {
    /// @notice Lot 0 is never cut; the Exchequer starts at 1.
    function seedOf(uint256 lot) public pure returns (bytes32) {
        return keccak256(abi.encodePacked("PAPERSTOCK/LOT/", lot));
    }

    // ── the tables ───────────────────────────────────────────────────────
    //
    // Sixteen commodities, sixteen ports, eight units, four grades. All of
    // them were ordinary entries on a bonded warrant once. None of them is
    // here now.

    function _goods(uint256 i) private pure returns (bytes32) {
        bytes32[16] memory t = [
            bytes32("Bolivian tin"), "bonded rum", "Manila hemp", "pressed cotton",
            "crude antimony", "dried cochineal", "raw shellac", "gum arabic",
            "whale oil", "saltpetre", "Ceylon graphite", "pig iron",
            "ground indigo", "Baltic amber", "smoked herring", "quicksilver"
        ];
        return t[i];
    }

    function _port(uint256 i) private pure returns (bytes32) {
        bytes32[16] memory t = [
            bytes32("Valparaiso"), "Riga", "Macassar", "Pernambuco",
            "Archangel", "Smyrna", "Trebizond", "Batavia",
            "Callao", "Zanzibar", "Bilbao", "Hobart",
            "Canton", "Odessa", "Antofagasta", "Vera Cruz"
        ];
        return t[i];
    }

    function _unit(uint256 i) private pure returns (bytes32) {
        bytes32[8] memory t = [
            bytes32("tonnes"), "casks", "bales", "chests",
            "puncheons", "hogsheads", "cases", "piculs"
        ];
        return t[i];
    }

    function _grade(uint256 i) private pure returns (bytes32) {
        bytes32[4] memory t = [bytes32("first"), "second", "merchantable", "fair average"];
        return t[i];
    }

    // ── the cargo ────────────────────────────────────────────────────────

    /// @notice Everything the register knows about a lot, which is nothing.
    /// @return goods    the commodity
    /// @return port     the port of lading
    /// @return quantity how much of it there is not
    /// @return unit     the measure it is not counted in
    /// @return grade    the quality it was never inspected to
    /// @return mark     the lot mark, stencilled on crates that do not exist
    function cargo(uint256 lot)
        public
        pure
        returns (
            string memory goods,
            string memory port,
            uint256 quantity,
            string memory unit,
            string memory grade,
            string memory mark
        )
    {
        bytes32 h = seedOf(lot);
        goods = _str(_goods(uint8(h[0]) & 0x0f));
        port = _str(_port(uint8(h[1]) & 0x0f));
        unit = _str(_unit(uint8(h[2]) & 0x07));
        grade = _str(_grade(uint8(h[3]) & 0x03));

        uint256 raw = (uint256(uint8(h[4])) << 8) | uint256(uint8(h[5]));
        quantity = 20 + (raw * 9980) / 65535;

        bytes memory m = new bytes(5);
        m[0] = bytes1(uint8(65 + (uint8(h[6]) % 26)));
        m[1] = "-";
        uint256 n = 100 + (uint256(uint8(h[7])) % 900);
        m[2] = bytes1(uint8(48 + (n / 100)));
        m[3] = bytes1(uint8(48 + ((n / 10) % 10)));
        m[4] = bytes1(uint8(48 + (n % 10)));
        mark = string(m);
    }

    /// @notice The whole cargo as one line, the way it would print on a warrant.
    /// @dev    e.g. "1,240 casks of bonded rum, Pernambuco, fair average quality  [K-417]"
    function line(uint256 lot) external pure returns (string memory) {
        (string memory g, string memory p, uint256 q, string memory u, string memory gr, string memory mk) =
            cargo(lot);
        return string(
            abi.encodePacked(
                _commas(q), " ", u, " of ", g, ", ", p, ", ", gr, " quality  [", mk, "]"
            )
        );
    }

    // ── formatting ───────────────────────────────────────────────────────

    /// @dev A left-aligned, zero-padded bytes32 back to a string, trimmed at the first zero.
    function _str(bytes32 b) private pure returns (string memory) {
        uint256 n;
        while (n < 32 && b[n] != 0) {
            unchecked { ++n; }
        }
        bytes memory o = new bytes(n);
        for (uint256 i; i < n;) {
            o[i] = b[i];
            unchecked { ++i; }
        }
        return string(o);
    }

    /// @dev Thousands separators, because a manifest that reads "1240 casks" reads like
    ///      a database and a manifest that reads "1,240 casks" reads like a document.
    function _commas(uint256 v) private pure returns (string memory) {
        if (v == 0) return "0";
        uint256 digits;
        for (uint256 t = v; t != 0; t /= 10) {
            unchecked { ++digits; }
        }
        uint256 len = digits + (digits - 1) / 3;
        bytes memory o = new bytes(len);
        uint256 w = len;
        uint256 c;
        while (v != 0) {
            if (c == 3) {
                o[--w] = ",";
                c = 0;
            }
            o[--w] = bytes1(uint8(48 + (v % 10)));
            v /= 10;
            unchecked { ++c; }
        }
        return string(o);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.