Nexa uses Bech32 addressing. It follows the CashAddr format, with a few modifications as described below.
For succinctness, this specification does not stand alone – it defines a change set to CashAddr.
All length restrictions are removed.
The CashAddr version byte (first byte) section should be replaced with this information:
For script template address types, the first byte MUST be 152. This begins each address with “n”, and defines the contents as specified below.
For group (token) identifiers the first byte MUST be 88. This begins each address with “t”.
For legacy (pay-to-pubkey-hash) address types, the first byte MUST be 0. This is as defined in the CashAddr spec.
Base58 encoding is not recommended. It is not necessary to for services to accept Base58 encoded addresses. However, if used, the prefix should be the 1 byte value “8”, and the contents as specified below.
The contents of an address is a serialized output script. To be precise, first create a byte array of the full script. Then serialize that byte array in the standard bitcoin serialization manner (effectively prepending the script with its length as a compact int). All such scripts are assumed to be script templates. If the script defines a group (tokens) but not a token quantity, use OP_0 as the quantity. This will render the output script illegal until the sender modifies the script with their desired token quantity. Addresses MAY also specify a desired quantity by including the field… which, of course, may be overridden by the sender or not as the sender chooses.
The following sections apply the above description to clarify the address contents for common use cases (but do not add any additional info).
Note that since script template formatted output scripts are easily distinguishable from most other output scripts, this restriction may be selectively eased for other script types.
See dstencode_tests.cpp for test vectors.
OP_0 # No group
OP_1 # Well known template 1
PUSH Hash160(Script(PUSH pubkey))
[Optional: TBD additional data (do not rely on the size to identify this address form)]
Example
nexa:nqtsq5g5w6syq5aa5z5ghkj3w7ux59wrk204txrn64e2gs92
PUSH GroupId
OP_0 # Unspecified token amount
OP_1 # Well known template 1
PUSH Hash160(Script(PUSH pubkey))
[Optional: TBD additional data (do not rely on the size to identify this address form)]
Example
nexa:nqazqy3uqsp4j0zyyufqzy65qc2u9vvm2jthyqgzqvzq2ps8pqys5zcvqgqqq5g5w6syq5aa5z5ghkj3w7ux59wrk204txrn92xzqzsu
OP_0 # No group
PUSH Hash160/256(Script(… your contract…))
PUSH Hash160/256(Script(PUSH your args …))
[Optional: PUSH visible args]…
[Optional: TBD additional data]…
Example
nexa:nq4sq9rk5pq980dq4z9a55thhp4ptsajna2esuc5zg7qgq6e83zzwyspzd2qv9wzkxd4f9mjwp6hsdfn
PUSH GroupId
OP_0 # Unspecified token amount
PUSH Hash160/256(Script(… your contract…))
PUSH Hash160/256(Script(PUSH your args …))
[Optional: PUSH visible args]…
[Optional: TBD additional data]…
Example
nexa:np9sq9rk5pq980dq4z9a55thhp4ptsajna2esuc5zg7qgq6e83zzwyspzd2qv9wzkxd4f9mjzg7qgq6e83zzwyspzd2qv9wzkxd4f9mjqypqxpq9qcrsszg2pvxq3p2q9kaa
OP_0 # No group
PUSH Hash160/256(Script(… your contract…))
OP_0 # No args
[Optional: PUSH visible args]…
[Optional: TBD additional data]…
nexa:nqtsq9rk5pq980dq4z9a55thhp4ptsajna2esucqqj42vk56