Verified contractExactMIT
Foil
Address0x4e65da2cc258eb91bbe86249ec3123d1e959bccf
- Balance
0 ETH
- Transactions
2
- 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,337
- Creation transaction
- 0x9ad5db0a70…9487a9a4f9
paperstock/Foil.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
// P A P E R S T O C K
// ══════════════════════════════════════════════════════════════════════════
// web paperstock.fun
// ──────────────────────────────────────────────────────────────────────────
// Foil.sol · THE OTHER HALF OF THE STICK
// 3 of 6 · holds no ether, owns no token, accepts one writer for ever
// ══════════════════════════════════════════════════════════════════════════
//
//
// WHY IS IT CALLED THE FOIL?
//
// A tally was split down its length and the two halves went to different
// people. The creditor took the stock. The Exchequer kept the foil, and
// the foil was the control: notches cut before the split had to line up
// across the grain, and hazel does not split twice the same way. A stock
// presented for payment was laid against its foil in front of a clerk.
// If the halves did not match, the claim was not honoured. The fraud
// control was the wood.
//
// This contract is the foil. It is the record kept on the other side of
// the claim, written by something with no interest in the outcome, and a
// tally is not honoured unless it matches.
//
// WHAT DOES IT RECORD?
//
// One number, and the restraint is the whole design: THE NUMBER OF
// SEPARATE DAYS ON WHICH THIS POOL HAS TRADED AT ALL.
//
// Not volume. Not price. Not fees. Days. The hook calls in after every
// swap; if the UTC day has already been counted, nothing at all happens
// and nothing is written. The first swap of a new day moves the counter
// by exactly one and that is the most this contract can ever do in
// twenty-four hours.
//
// WHY DAYS AND NOT MONEY?
//
// Because money is the one thing a single address can fake in a single
// block, and the Exchequer needs at least one gate that cannot be
// crossed by being rich.
//
// A lot is only honoured if its tally was fully backed AND the pool was
// open on enough separate days across the tally's life. The first
// condition can be bought outright. The second cannot be bought at any
// price, by anybody, because the only thing that buys it is the calendar.
// You can fund a tally in one transaction. You cannot make it Tuesday.
//
// That is the whole of it. A claim nobody ever came to trade against is
// not a claim, it is a story, and this counter is how the register tells
// the difference.
//
// WHAT CAN IT DO TO ME?
//
// Nothing. It cannot hold ether — there is no payable function and no
// receive. It cannot hold a token. It has no owner. Its one writer is
// set once by a wiring role that deletes itself in the same transaction,
// and after that the writer can never be changed, added to or removed,
// by anyone, for any reason.
//
// On the swap path it is one storage read and a comparison, and on the
// first swap of a day, one write. That cost is published in
// paperstock/measured.json rather than described.
//
// WHAT COULD MAKE THIS WORTHLESS?
//
// A determined party with a lot of time can satisfy it. One swap of one
// wei a day, for the required number of days, counts exactly as much as
// a day of real trading — this contract cannot tell an active market
// from a patient one and does not claim to. What it costs to fake is
// gas, and calendar days, every one of them in public and on chain where
// anybody deciding what a tally is worth can see the pattern. It raises
// the floor on the cheapest possible lie from one block to several
// weeks. It does not make lying impossible.
//
// And it measures a pool, not a world. If the pool is quiet because
// everyone has moved on, the counter is right and the tally deserves to
// mature short. If the pool is quiet because of something with nothing
// to do with the register, the counter is still right and the tally still
// matures short. It has no way to tell those apart, and it will not be
// taught to.
//
contract Foil {
/// @notice Separate UTC days this pool has traded on. Never falls, never jumps.
uint32 public dayCount;
/// @notice The day of the very first swap. Zero until then.
uint32 public firstDay;
/// @notice The most recent day counted.
uint32 public lastDay;
/// @notice The only address that may ever write here. Packed with the three
/// counters above, so a day is recorded in a single storage word.
address public hook;
/// @notice Deleted by {wire}, in the call that uses it.
address public wirer;
event Opened(uint32 day, uint32 count);
event Wired(address hook);
error NotHook();
error NotWirer();
error ZeroAddress();
constructor(address _wirer) {
if (_wirer == address(0)) revert ZeroAddress();
wirer = _wirer;
}
/// @notice Name the one writer, once, and delete the role that did it.
function wire(address _hook) external {
if (msg.sender != wirer) revert NotWirer();
if (_hook == address(0)) revert ZeroAddress();
hook = _hook;
wirer = address(0);
emit Wired(_hook);
}
/// @notice The hook calls after every swap. Nearly every call does nothing.
function note() external {
if (msg.sender != hook) revert NotHook();
uint32 d = uint32(block.timestamp / 1 days);
if (d == lastDay) return; // already counted today — no write at all
lastDay = d;
if (firstDay == 0) firstDay = d;
unchecked { ++dayCount; }
emit Opened(d, dayCount);
}
// ── reading ──────────────────────────────────────────────────────────
/// @notice Today, in the same units the counter uses.
function today() public view returns (uint32) {
return uint32(block.timestamp / 1 days);
}
/// @notice Days counted since a mark taken earlier. This is what the Exchequer asks.
function since(uint32 mark) external view returns (uint32) {
uint32 c = dayCount;
return c > mark ? c - mark : 0;
}
/// @notice Whole days since the pool last traded. Zero on a day it has.
function silence() external view returns (uint32) {
uint32 l = lastDay;
if (l == 0) return 0;
uint32 t = today();
return t > l ? t - l : 0;
}
/// @notice The whole record in one call.
function record()
external
view
returns (uint32 days_, uint32 opened, uint32 latest, uint32 span, address writer)
{
days_ = dayCount;
opened = firstDay;
latest = lastDay;
span = opened == 0 ? 0 : today() - opened + 1;
writer = hook;
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.