const AvgBlockMs
AvgBlockMs is the measured mainnet average block time (RA §1: 200k blocks in 708,660 s). Use it only for UI estimates and defaults; every on-chain rule is stated in blocks.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package safe holds the pure checks and formulas every platform realm shares: text and SVG validation, basis-point mat...
Package safe holds the pure checks and formulas every platform realm shares: text and SVG validation, basis-point math, payee splits, merkle proofs, provenance hashes and the one JSON writer. Nothing here has state.
AvgBlockMs is the measured mainnet average block time (RA §1: 200k blocks in 708,660 s). Use it only for UI estimates and defaults; every on-chain rule is stated in blocks.
BpsDenominator is 100% in basis points (EIP-2981, royalty/v0).
Domain separates every hash this platform commits to from hashes of the same bytes made for any other purpose. It equals the brand slug and changes with it (paths change anyway when the brand is chosen).
MaxMerkleDepth bounds a proof: 2^32 leaves is far beyond any allowlist.
AllowlistLeaf is the leaf for addr in collection cid's allowlist tree.
AssertBps panics unless 0 <= bps <= cap.
AssertHex checks that s is exactly nBytes of hex and returns it lowercased.
AssertNonEmptyText is AssertText that also refuses "".
AssertSVG checks an engine's raw SVG output: size, envelope, the forbidden constructs above, inline event handlers, and any href or url() that does not point inside the document. The frontend shows art only through <img>, which never runs scripts; this check is the defence in depth for every other place a data: URI ends up (RA M-7, design §5.4).
AssertSymbol enforces the grc721 symbol alphabet ([A-Za-z0-9_-], 1..11 bytes) up front, so the error names the field instead of surfacing from grc721.NewToken.
AssertText panics with the field name when CheckText rejects s.
BlocksFor converts a duration to blocks, rounding up.
BpsOf returns floor(amount * bps / 10000) without ever forming the full product, so it cannot overflow for any amount >= 0 and 0 <= bps <= 10000.
CheckText reports why s may not be stored as user-visible text.
Rejected: invalid UTF-8; C0 and C1 control characters, which include tab, newline and carriage return (the record-injection vector of RA H-1); DEL; U+2028/U+2029, which end a line in older JavaScript parsers (RA L-12); and every bidi control or zero-width character that lets one string render as another.
Commit is the value a creator ("creator") or the beacon ("beacon") commits to for collection cid on chain chainID.
FormatPayees is the inverse of ParsePayees.
InitialEntropy seeds a collection's mint-entropy accumulator.
JSONString returns s as a quoted JSON string. Beyond the mandatory escapes it also escapes U+2028/U+2029 (RA L-12) and '<', '>', '&', so the output is safe to inline in HTML as well.
MerkleParent is hashPair on hex nodes, for tests and the off-chain builder.
MerkleVerify checks a sorted-pair sha256 proof ("hex,hex,…", leaf to root). An empty proof means the tree has a single leaf equal to the root. Malformed input is simply false: proofs come from untrusted callers.
MixEntropy folds one mint call into the accumulator. The inputs are public, but none existed when the secrets were committed, which is what stops a committer from choosing the map their own mints receive.
PadHex renders n in lowercase hex, zero-padded to width.
PadInt renders n with leading zeros to width digits, so decimal ids and prices sort correctly as avl keys. n must be >= 0.
ParseID parses a positive decimal id ("1", "42"). Leading zeros, signs and empty strings are refused so every id has exactly one spelling.
ParsePayees parses "g1…:7000,g1…:3000": 1..max distinct valid addresses, each with a positive share, shares summing to exactly 10000.
Salt binds both secrets ("" when not revealed) to the final accumulator.
Seed is the per-token engine seed once the salt is final.
SplitByBps divides amount by the payees' shares. The rounding remainder goes to the first payee, so the parts always sum to exactly amount — the property every "no balance left behind" invariant (I-3, I-4) relies on.
XMLEscape makes s safe as SVG/XML character data or a quoted attribute.
JSONWriter is the single JSON producer of every read API (design §2.5: reads return primitives or JSON, never positional text). It tracks commas itself, so callers only describe structure:
Key starts an object member; the next value call writes its value.
Raw writes v verbatim. Only for JSON produced by another JSONWriter.
StrField and IntField are Key+value shorthands.