This section states the encoding by which a payee states payments to a payer. It gives the URI grammar of ZIP 321, the grouping of parameters into payments and the conditions under which a parser accepts a URI; then the meaning of the address, amount, memo, label and message parameters, the capacity of one request, and the passage from an accepted request to a transaction plan.
A payment request precedes planning (§11.1): the payee states to the payer, in a form that a wallet reads mechanically, the recipient addresses, amounts and memos of the payments it asks for, and ZIP 321 fixes this encoding as a URI scheme. Its terms payment and payment request (ZIP 321, “Terminology”) are those of Definition 11.1. Everything that follows once the recipients are fixed is constructed in the earlier sections of this volume and in the Ironwood Guide, §“Note encryption”, §“Trial decryption and note acceptance”, §“Authentication paths”, §“Anchors” and §“Transaction digests and signatures”; this section re-derives none of it. The status of ZIP 321 is that of Table 1.
Let be the set of strings derived from zcashurn in the following grammar in ABNF (RFC 5234), reproduced from ZIP 321, “URI Syntax”, with its longest rule continued on an indented line:
zcashurn = "zcash:" ( zcashaddress [ "?" zcashparams ]
/ "?" zcashparams )
zcashaddress = 1*( ALPHA / DIGIT )
zcashparams = zcashparam [ "&" zcashparams ]
zcashparam = [ addrparam / amountparam / assetparam / memoparam
/ messageparam / labelparam / otherreqparam / otherparam ]
NONZERO = %x31-39
DIGIT = %x30-39
paramindex = "." NONZERO 0*3DIGIT
addrparam = "address" [ paramindex ] "=" zcashaddress
amountparam = "amount" [ paramindex ] "=" 1*DIGIT [ "." 1*8DIGIT ]
assetparam = "req-asset" [ paramindex ] "=" *base64url
labelparam = "label" [ paramindex ] "=" *qchar
memoparam = "memo" [ paramindex ] "=" *base64url
messageparam = "message" [ paramindex ] "=" *qchar
paramname = ALPHA *( ALPHA / DIGIT / "+" / "-" )
otherreqparam = "req-" paramname [ paramindex ] [ "=" *qchar ]
otherparam = paramname [ paramindex ] [ "=" *qchar ]
qchar = unreserved / pct-encoded / allowed-delims / ":" / "@"
allowed-delims = "!" / "$" / "’" / "(" / ")" / "*" / "+" / "," / ";"
Here ALPHA, unreserved and pct-encoded are those of RFC 3986, Appendix A, and base64url is the alphabet of RFC 4648, Section 5, in which the values and are written - and _, with padding omitted. The grammar is read as follows: a parameter whose name is address, amount, label, memo, message or req-asset is derived only by its own production, and otherreqparam and otherparam derive only parameters with other names. A payment request URI is a string of that meets the acceptance conditions (a) to (f) stated below in this subsection.
Without the reading, otherparam would derive amount=1%30, with name amount, no index and a qchar value; ZIP 321, “Invalid Examples”, rejects a URI with this parameter.
Surface forms. The grammar derives no // after the scheme, so a payment request URI has no authority component and is not hierarchical in the sense of RFC 3986, Section 1.2.3; ZIP 321, “Invalid Examples”, rejects zcash:// followed by an address. A URI , with a zcashaddress, MUST be treated as (ZIP 321, “URI Semantics”). A request for a single payment SHOULD place its address in the hier-part; several payments are written with addrparam at distinct indices (same section). By this equivalence and condition (b) below, a URI is not accepted: after the rewriting it carries address twice at the empty index.
Indices and grouping. Identify the empty index with and let . The rendering maps to the empty string and to , where is the decimal representation of without leading zeros. The strings that match [ paramindex ] are the empty string and the strings with , and decimal digits; these are exactly the decimal representations without leading zeros of the integers to . Hence is a bijection from onto the index suffixes, and its inverse is parsing. The strings .0, .01 and .10000 match no production, and ZIP 321, “Invalid Examples”, rejects address.0= and amount.0=. Parameters whose suffixes denote the same index , the empty index included, belong to one payment ; the order of the parameters is insignificant, and indices need not be consecutive (ZIP 321, “URI Semantics”). A URI therefore decodes to a finite map on a subset of , and carries at most payments: at indices to and one at the empty index.
Lexical rules. Percent encoding (RFC 3986, Section 2.1) occurs only inside qchar, that is, only in the values of label, message, otherreqparam and otherparam. Addresses, amounts, indices and parameter names are literal, so amount=1%30, %61mount=1 and an address beginning with %74 are not in (ZIP 321, “URI Syntax” and “Invalid Examples”). The values of memo and req-asset are base64url without padding, and implementations MUST NOT accept the characters +, / and =, which occur only in the standard base64 alphabet (ZIP 321, “URI Syntax”; RFC 4648, Section 5).
Acceptance. A parser accepts a string as a payment request URI only if all of the following hold (ZIP 321, “URI Syntax”, “URI Semantics” and “Forward compatibility”):
after the hier-part address is rewritten as address at the empty index, no pair of a parameter name and an index occurs twice (MUST NOT);
every index that carries a parameter other than address carries an address (MUST);
names no parameter with prefix req- that the parser does not recognise, since such a parameter makes the entire URI invalid (MUST); other unrecognised parameters are ignored (SHOULD);
the address, amount and memo rules of §14.2 hold;
decodes to at least one payment, a payment request containing one or more payments (ZIP 321, “Terminology”).
The prefix req- is part of the name of a parameter defined by a later revision of ZIP 321, not a modifier of an arbitrary parameter; the parameters address, amount, label, memo and message never carry it, since every conformant parser is required to understand them (ZIP 321, “Forward compatibility”). An accepted URI asks for one transaction: implementations SHOULD construct a single transaction that pays every address of the request (ZIP 321, “URI Semantics”).
Custom assets. The parameter req-asset is specified in ZIP 321, “Custom Assets”, with an encoding defined by ZIP 227, which the protocol described in this volume does not include. A parser of this protocol does not recognise req-asset, so by condition (d) a URI that carries it is invalid to that parser, and the further rule that amount and req-asset exclude each other at one index (ZIP 321, “URI Semantics”) never applies.
Quoted strings in ABNF are case-insensitive (RFC 5234, Section 2.3), so contains strings beginning ZCASH: and strings with the parameters AMOUNT=1 and REQ-ASSET=; the value ranges NONZERO and DIGIT, given as %x ranges, and the base64url alphabet are case-sensitive. ZIP 321 does not address case: it states neither whether such URIs are to be accepted nor whether amount and AMOUNT at one index are the same parameter for condition (b). The volume states the grammar as written and resolves neither question; no parser’s behaviour is normative. Class: open problem (Definition 1.1).
Addresses. Implementations SHOULD check that each zcashaddress is a valid encoding of an address other than a Sprout address under protocol specification, §“Encodings of Addresses and Keys”: a transparent address (§“Transparent Addresses”, Base58Check), a Sapling payment address (§“Sapling Payment Addresses”, Bech32, ZIP 173) or a unified address (§“Unified Payment Addresses and Viewing Keys” and ZIP 316, Bech32m, BIP 350). Address formats later added to that section SHOULD be supported; where the network of the request is known, each address SHOULD be checked to belong to it; and every requirement of ZIP 316 applies to a unified address (ZIP 321, “URI Semantics”). Sprout addresses MUST NOT be supported (same section). ZIP 321 gives as its reason the restriction of ZIP 211 on adding value to the Sprout pool; in the protocol described, version- transactions are invalid, and Sprout transfers exist only in transactions of versions to , so Sprout funds are unspendable (ZIP 2003, “Abstract”; ZIP 259, “Abstract”; Ironwood Guide, §“The transaction format”). A TEX address (ZIP 320) is in no section of the specification, and ZIP 321 names none; its reading as the recipient address of item 4 of Definition 3.20 is designed but unspecified (Definition 1.1). The addresses of an accepted request are thus recipient addresses in the sense of Definition 3.20.
Let zatoshi per ZEC (Ironwood Guide, Definition “Unit of value” in §“Notes”) and zatoshi (Ironwood Guide, §“The transaction format”), so that ZEC is zatoshi. For a string of decimal digits, let be the natural number it denotes, leading zeros ignored, and let be the string of characters 0.
Parse. Let match 1*DIGIT [ "." 1*8DIGIT ], and write or with its whole part and its fraction. Set , or without a fraction, and
Accept if and only if ; an accepted denotes zatoshi, and .
Render. For write with . Let be if , and otherwise , where is the -digit zero-padded decimal representation of with its trailing characters 0 removed.
Leading zeros of the whole part and trailing zeros of the fraction are ignored, the bound is ZIP 321’s “MUST NOT be greater than 21000000 ZEC”, and a string with a comma or other grouping separator, with an empty whole part (.5), an empty fraction (50.) or more than fraction digits matches no production (ZIP 321, “ZEC Transfer Amount”). ZIP 321 fixes only the value that an amount denotes; the rendering is canonical, not required.
For every , the string matches 1*DIGIT [ "." 1*8DIGIT ] and . The map is not injective. For every accepted , is the unique string of value whose whole part has no leading zero unless it is the single character 0, whose fraction has no trailing zero, and which has no fraction when is a multiple of .
Write with . The string is non-empty. If , then matches the production, and returns . If , the -digit form of has a non-zero digit, so removing its trailing zeros leaves a fraction with , and the production matches. Appending zeros to restores the -digit form of , so returns , and accepts since . The strings 50, 050 and 50.00 all denote zatoshi, so is not injective. Finally, an accepted determines , which are the quotient and remainder of by since . A string of the stated form is fixed by these two numbers: its whole part is , and its fraction is absent if and otherwise the -digit form of without trailing zeros. That string is . □
Examples. On the examples of ZIP 321, “ZEC Transfer Amount” and “Examples”, Construction 14.3 gives the following. The parameter amount=1 denotes zatoshi, amount=123.456 denotes zatoshi, and amount.1=0.789 denotes zatoshi for the payment at index . The values 50, 050 and 50.00 denote zatoshi, and 0.5 and 00.500 denote zatoshi. The value 21000000 denotes zatoshi and is accepted, while 21000000.00000001 exceeds and is rejected. The values 50,000.00, 50,00, 50., .5 and 0.123456789 are invalid. The parameters address.0= and amount.0= are invalid, their index having a leading zero, and so is any parameter with the five-digit suffix .10000.
Absent amount. ZIP 321 gives a payment a value only “if an amount parameter is provided” (ZIP 321, “ZEC Transfer Amount”). A payment without one has no value under ZIP 321, while Definition 11.1 requires a value, so the payer fixes the value before a plan is formed. Class: designed but unspecified (Definition 1.1).
A memo is a -byte string , the memo field of a note plaintext (Ironwood Guide, §“The note plaintext”; protocol specification, §“Encodings of Note Plaintexts and Memo Fields”). Let be the encoding of RFC 4648, Section 5, with padding omitted, and let be with its trailing bytes removed.
Encode. , a string of at most characters.
Decode. Reject a value that contains a character outside the base64url alphabet, in particular +, / or =, or whose length is congruent to modulo , a length to which no octet string encodes. Otherwise let be its decoding under RFC 4648, Section 5, and require (MUST); then (ZIP 321, “Query Keys”).
A payment without a memo parameter has no memo (Definition 11.1); its output, if shielded, carries the memo field that ZIP 302 designates as supplying no memo, , whose encoding is 9g (ZIP 302, “Specification”). A parameter memo= with the empty value differs from an absent parameter: it decodes to , which a reader under ZIP 302 reads as the empty text. If the address at the index of a memo parameter does not permit memos, that is, is not memo-capable in the sense of predicate (i) of Definition 3.20, as for a transparent or TEX address, parsers MUST consider the entire URI invalid (ZIP 321, “Query Keys”), since a memo travels only in a note plaintext.
For every memo , .
The string uses only the base64url alphabet, and an unpadded encoding of octets has length , never congruent to modulo , so decoding does not reject it. The encoding is injective with inverse the decoding of RFC 4648, so , and . The bytes that removes are zeros, so appending zeros to returns . □
ZIP 321 does not say whether a value whose final character carries non-zero unused bits (RFC 4648, Section 3.5) is accepted; the encoding produces none. Stripping trailing zeros gives the shortest encoding and is not required: decodes to the same memo. As an instance, ZIP 321’s example value VGhpcyBpcyBhIHNpbXBsZSBtZW1vLg, of characters, decodes to the bytes of the text “This is a simple memo.”, padded with zeros to bytes.
Labels and messages. The label at an index names its address, for example by the name of the recipient; a client that renders the payment for inspection SHOULD display the label together with the address, and a displayed label MUST be identifiable as distinct from the address. The message at an index is descriptive text that a client may display for that payment (ZIP 321, “Query Keys”). Both values are qchar strings, percent-decoded to octet strings; an octet outside qchar reaches them only by percent encoding. Neither enters the transaction (Definition 11.1).
Capacity. A request carries at most payments (§14.1), and the one transaction it asks for is bounded further by consensus; the bound that binds is the least of the following.
Size. A block has at most bytes (protocol specification, §“Block Header Encoding and Consensus”), and a Sapling output contributes at least bytes to a transaction, so a transaction has at most Sapling outputs (protocol specification, §“Balance and Binding Signature (Sapling)”). This is the bound that ZIP 321, “URI Semantics”, states.
Shielded budget. ZIP 218, part of NU7, requires of every block, with the number of Sapling spends plus outputs, the number of Orchard-pool Actions and the number of JoinSplit descriptions, each summed over the block’s transactions,
(ZIP 218, “Shielded pool action limits”). Versions and carry no JoinSplit description (Ironwood Guide, §“The transaction format”), so . Each of these sums over a block is at least the term of any one of its transactions. A transaction that pays payments by Sapling outputs has Sapling outputs; with Sapling spends and Orchard-pool Actions it is mined only if and , hence only if
The all-Sapling bound is therefore outputs, fewer with spends or Orchard-pool Actions, and the bound of (i) never binds; one transaction carries at most units of the shared budget.
Ironwood pool and transparent outputs. ZIP 218 as written counts neither Ironwood-pool Actions nor transparent components, so payments by Ironwood-pool or transparent outputs are bounded by the size limit alone. Whether Ironwood-pool Actions enter the shared budget is an open proposal (Consensus Guide, §“A block budget for shielded work”). Class of (iv): open problem (Definition 1.1).
From request to plan. Each payment of an accepted request, its value fixed by the payer if absent, is a payment in the sense of Definition 11.1 and becomes one output of the plan: its pool is that of Construction 11.5, a TEX address is paid by Construction 11.7, and its memo, if any, is the memo field of that output’s note plaintext (Construction 14.5). A TEX payment funded from shielded notes needs the two transactions of Construction 11.7, so the MUST of ZIP 320, “Design considerations for Senders”, and not the SHOULD of ZIP 321 that asks for a single transaction, fixes the shape of such a plan. From there construction is that of §11.1 and Constructions 11.18 and 11.20: an Orchard-protocol output is sealed as in the Ironwood Guide, §“Encryption to the recipient”, a Sapling output as in the protocol specification, §“Sending Notes (Sapling)”, and the Ironwood Guide, §“Transaction digests and signatures”, gives the digest that every signature signs.