Contract reference
Every external function across MailRegistry and MailBox, with parameters, access control and behaviour.
Two contracts, both Solidity 0.8.24 targeting the cancun EVM.
MailBox holds an immutable reference to MailRegistry
and calls a single method on it.
MailRegistry: reading
| Function | Returns | Notes |
|---|---|---|
nameHash(string) | bytes32 | Pure. The canonical key for every name mapping. |
isRegistered(address) | bool | The only method MailBox calls. |
pubkeyOf(address) | bytes32 | Current published X25519 key. |
resolve(string) | address | Name to wallet. Zero if unclaimed. |
lookup(string) | wallet, pubkey, keyVersion, epoch | One call for everything a sender needs. |
feeFor(string) | uint256 | Priced on visible length, hyphens excluded. |
unavailableReason(string, address) | reason | Why a name cannot be taken, for useful client errors. |
isValidName(string) | bool | Charset, length and hyphen placement. |
isValidPubkey(bytes32) | bool | Rejects zero, top-bit-set, and six small-order points. |
skeleton(string) | string | Confusable folding. Advisory only, never enforced. |
MailRegistry: writing
register
function register(string calldata name, bytes32 x25519Pubkey, uint256 maxFee)
external payable
Mints a name to msg.sender and publishes its encryption key.
Reverts if the wallet already holds a name, the name is taken, reserved, invalid,
or inside another owner's release grace. Overpayment above the required fee is
refunded; maxFee caps exposure to a price change.
rotateKey
function rotateKey(bytes32 newPubkey) external
Publishes a new key and increments keyVersion. The previous key
stays in keyHistory, so older mail remains readable.
Transfers
TRANSFER_WINDOW.RELEASE_GRACE window in which only the previous owner may re-register it.Owner-only
MAX_RESERVE_BATCH (256). Never dispossesses an existing holder; emits ReservedWhileRegistered instead.price3 and price4.OWNERSHIP_WINDOW.There is no function that reassigns a registered name, reads mail, or changes a published key on someone's behalf. Owner powers are limited to reservations, pricing, and withdrawing fees.
MailBox: reading
| Function | Returns | Notes |
|---|---|---|
requiredStamp(recipient, sender) | uint256 | What this sender must escrow right now. |
canSend(recipient, sender, envelopeBytes) | ok, reason, required | Pre-flight check, so the client can explain a failure before spending gas. |
isAllowed(recipient, sender) | bool | Allowlist membership, respecting its expiry. |
stamps(mailId) | Stamp | Escrow row for one message. |
credits(address) | uint256 | Value owed after a failed push payment. |
mailCount() | uint256 | Total messages emitted; the source of mailId. |
MailBox: sending
function send(
address to,
bytes calldata envelope,
uint256 inReplyTo,
uint256 maxStamp
) external payable
MAX_ENVELOPE_BYTES.mailId, or zero. If it names a live stamp this recipient paid to reach the sender, the required stamp drops to zero.The Mail event is emitted before settlement, so
delivery is never contingent on a payout succeeding.
MailBox: settlement
MAX_BATCH. Skip inapplicable rows rather than reverting; emit BatchSettled.MailBox: inbox controls
minStamp and MAX_STAMP.Constants
| Contract | Constant | Value |
|---|---|---|
| MailRegistry | TRANSFER_WINDOW | 7 days |
| MailRegistry | RELEASE_GRACE | 7 days |
| MailRegistry | OWNERSHIP_WINDOW | 7 days |
| MailRegistry | MAX_RESERVE_BATCH | 256 |
| MailBox | STAMP_EXPIRY | 30 days |
| MailBox | MAX_ENVELOPE_BYTES | 32 KB |
| MailBox | FREE_ENVELOPE_BYTES | 4 KB |
| MailBox | MAX_STAMP | 100 ether |
| MailBox | MAX_BATCH | 64 |
| MailBox | PAYOUT_GAS | 60,000 |