#NACRE Protocol Specification
This page is the protocol for NACRE, written for someone building an indexer or a wallet from the current code. Every price, fee, and output below can be recomputed with integer arithmetic. The first keyless launchpad on Pearl.
The rules were checked on a local Pearl test chain. There is no external audit yet. Mainnet figures are pending, and every number below is from that local run or from the current code.
#Status
A local test chain run on 2026-11-22 confirmed a launch, curve buys, a transfer, a curve sell, fills through all 800 layers, the harvest that moves the pool into the on-chain market, and market buys and sells. The same run reorganized two blocks and, after replay and an indexer restart, matched pool balance, holdings, trades, and candles. The record is the end-to-end report. A separate local run recorded curve sells between 2,150 vB and 2,220 vB. Those runs do not replace an external audit.
#How to read this page
NACRE is the product. Pearl is the chain. PRL is the native coin. A pearl is one token launched on NACRE. The pool is the script-locked output that holds that pearl's PRL. The pool is keyless: it has no private key, and it can move only when a transaction satisfies one of its scripts.
A layer is one position on the curve. The code stores the layer index in step, from 0 through 800. The code stores the number of layers in one trade in lots. This page says "layer" in prose and uses those names only for fields. Selling all 800 layers moves the pearl to the on-chain market. The product name for that move is harvested. The code calls the transaction graduate. This page says harvested after this sentence.
Amounts of PRL are in grain. 1 PRL is 100,000,000 grain. Token amounts are whole tokens, never a fraction. Do not store either amount in floating point.
Inside a transaction, a txid is in internal byte order: reverse the 32 display bytes, then append the 4-byte little-endian output index. Amounts of PRL are 8-byte little-endian grain. A token amount a is the 4-byte field AMT(a) = le32(a + 2^24). That encoding is also the shortest script number for a. AMT(0) is the bytes 00 00 01 00. a is an integer from 0 through 1,000,000,000.
The modules below are the source of the rules. When an older design note disagrees with them, follow the code.
| Module | Path | What it fixes |
|---|---|---|
| Curve price | packages/protocol/src/curve/price.ts, curve/pool.ts | Reserve table, leaf order, Taproot tree |
| State and token leaves | packages/protocol/src/token/state.ts, token/leaf.ts | 61-byte record, 24 token leaves, provenance |
| Curve buy | packages/protocol/src/pool/leaf.ts, pool/build.ts | Buy leaf, witness, launch layout |
| Curve sell | packages/protocol/src/poolsell/leaf.ts, poolsell/build.ts | Same template, sell constants |
| Launch | packages/protocol/src/launch/index.ts, launch/genesis.ts, launch/envelope.ts | Commit, reveal, inscription |
| Harvest | packages/protocol/src/graduate/leaf.ts, graduate/tx.ts | Last curve state to the market pool |
| Market | packages/protocol/src/market/price.ts, graduate/amm/leaf.ts, graduate/amm/tx.ts | Market table and its buy and sell leaves |
#Parameters
#Constants
| Item | Value | Name in code |
|---|---|---|
| 1 PRL | 100,000,000 grain | GRAINS_PER_PRL |
| Total supply | 1,000,000,000 tokens | TOKEN_SUPPLY |
| Tokens in one layer | 1,000,000 | TOKENS_PER_LOT |
| Curve length | Layers 0 through 800. 800 layers are sold on the curve. 200,000,000 tokens stay in the pool for the market | CURVE_LOTS = 800 |
| Curve trade sizes | 1, 2, 5, 10, 20, or 50 layers | ALLOWED_STEP_LOTS |
Opening pool C[0] | 10,000 grain | initialPoolGrains |
Virtual token reserve x | 1,075,000,000 tokens | virtualTokenReserveTokens |
Virtual PRL reserve y | 103,125,000,000 grain | virtualPrlReserveGrains |
| Platform trade fee | 100 bps (1%), rounded up | DEFAULTS.tradeFeeBps |
| Launch fee | 500,000,000 grain (5 PRL), unless an operator sets another canonical value | LAUNCH_FEE_GRAIN |
| Token output value | 1,000 grain | TOKEN_UTXO_VALUE |
| Smallest change a builder will emit | 1,000 grain | minOutputGrains |
| Relay dust reference | 330 grain | p2trDustGrains |
| Commit change dust | 333 grain. A smaller commit change is omitted | local constant in the launch builder |
| Market states | -1,610 through 4,607, which is 6,218 states | AMM_MIN_STATE, AMM_MAX_STATE |
| Market trade sizes | 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377 | AMM_STEPS |
| Pool-move size cap | 3,000 vB. A builder throws past this | MAX_POOL_TX_VBYTES |
| Leaf version | 0xc0 | curve tree and market tree |
| Internal key | The BIP 341 point with no known private key | TAPROOT_UNSPENDABLE_KEY |
| Mainnet fee address | prl1phern7h3fyflh9e33f5qqzzm7v332jtrjsgcdepvru82dv0kscdxq02h0aq | PLATFORM_FEE_ADDRESS |
The published curve file is curve-params.json. Its SHA-256 is 3f6f9809b360cfaedfa95523c7629f7596a94fe07e8712c40124fe8418b4d953. The published market file is amm-table.json. Its SHA-256 is 21fd439f7639d050572e6a24a7073919cd659f568be66baf07d3de26ba075fb6. Recompute both from the formulas in this page. Do not use floating point.
#Which fee value is accepted
The platform trade fee is 100 bps (1%). NACRE indexes a launch only when the inscription and the price table both use that rate. Any other rate is rejected and is not recorded as a pearl. The decoder error is trade fee N bps rejected; platform rate is 100 bps.
Three library checks are wider than that rule, and they are not the indexing rule:
| Check | Integers it accepts |
|---|---|
makePriceTable | 0 through 10,000 |
Inscription parser validateTradeFee, genesis, and the market table | 1 through 10,000. A fee of 0 fails while the inscription is built |
| Decoder, by default | 100 only |
The leaves do not read the fee rate back. They contain the fee amount in grain, computed when the tree was built. A tree built at another rate can still be a valid script. NACRE does not list it. The on-chain scripts were not given a second copy of the number 100. The rate comes from DEFAULTS.tradeFeeBps.
The launch fee is separate. The decoder compares the launch-fee output with the canonical value trees.launchFee, then expectedLaunchFee, then DEFAULTS.launchFeeGrains (5 PRL). It does not compare the output with the amount the transaction claims. A short payment is launch fee mismatch and is not listed. If an operator changes the launch fee, the indexer has to pass that same value into the launch resolver or a correct launch is rejected too.
The miner fee is separate again. It is paid in grain from the spender's own PRL and is not subtracted a second time from a sell refund.
On mainnet the fee address must be PLATFORM_FEE_ADDRESS. On a test network the same configured address has to appear in the tree, the decoder, and the queue.
#Curve reserves
Let sold = step * 1,000,000, the tokens already sold at layer step.
C[0] = 10,000
C[step] = C[0] + floor(103,125,000,000 * sold / (1,075,000,000 - sold))step runs from 1 through 800. Each reserve must be strictly larger than the one before it, and no reserve may exceed 2^63 - 1 grain. The division is integer division. Writing the same formula in layers, floor(103,125,000,000 * i / (1,075 - i)), is the same number, because i layers are i * 1,000,000 tokens and the virtual token reserve scales the same way.
Check values from the default table:
| Layer | Pool reserve |
|---|---|
| 0 | 10,000 grain |
| 1 | 96,029,553 grain |
| 2 | 192,228,080 grain |
| 800 | 300,000,010,000 grain |
Layer 1 is the worked example. sold = 1,000,000. The fraction is floor(103,125,000,000 * 1,000,000 / 1,074,000,000) = 96,019,553. Adding the opening 10,000 grain gives 96,029,553 grain.
Inventory written into output 0 is tokens, not layers:
Y(step) = 1,000,000,000 - step * 1,000,000Layer 0 holds the full 1,000,000,000 tokens. Layer 800 holds 200,000,000 tokens.
#Quotes and the platform fee
quoteBuy and quoteSell use the reserve table:
D = abs(C[stepTo] - C[stepFrom])
F = ceil(D * tradeFeeBps / 10,000) = (D * bps + 9,999) // 10,000
buy settlement = D + F
sell settlement = D - FAt 100 bps, F = (D + 99) // 100. For the layer 0 to layer 1 buy, D = 96,019,553 grain and F = 960,196 grain. The buyer settles 96,979,749 grain. After the buy, the pool output must equal C[1] and the platform-fee output must equal F.
On a sell, the miner fee comes out of the seller's own PRL input. It is not subtracted again from D - F.
A market trade uses the same ceiling on abs(X_to - X_from). The market leaf builder also refuses a platform fee below 1,000 grain. The curve quote has no second floor.
#Leaf order on the curve
enumerateTransitions walks step from 0 through 799. At each layer it emits buys first, from the smallest trade size to the largest, keeping only sizes with step + lots <= 800. It then emits sells, keeping only sizes with step >= lots. Layer 800 has no sell leaf. The last leaf in the tree is the harvest leaf.
With the default sizes that is 4,718 buys, 4,712 sells, and 1 harvest leaf: 9,431 leaves. Count them from the rule above rather than hard-coding the total in a second place.
#Market table
At harvest, X_0 = C[800] = 300,000,010,000 grain and Y_0 = 200,000,000 tokens. The constant product is k = X_0 * Y_0.
Token reserves move away from Y_0 by the 60-decimal fixed-point factors 5^(1/1610) and 5^(-1/1610), then round half to even. The PRL reserve is ceil(k / Y_s). State -1,610 is fixed at Y_0 * 5 = 1,000,000,000 tokens, which is the whole supply. Neighboring states must have a strictly smaller token reserve and a strictly larger PRL reserve, so the PRL in the pool identifies exactly one state (stateFromPoolAmount).
Use these integers. SCALE = 10^60. A half-even rounding of a scaled value scaled takes the integer whole = scaled / SCALE. It rounds away from zero when 2 * (scaled % SCALE) > SCALE, and also when the remainder is exactly one half and whole is odd.
| Direction | Factor, the integer part of SCALE times 5 to the power +1/1610 or -1/1610 |
|---|---|
| Toward more tokens (state decreases) | 1001000150694760275774499109716182828129711690933480030673300 |
| Toward fewer tokens (state increases) | 999000848607199404438354486700711816566668247055847663535372 |
The implementation carries an outward-rounded upper bound one unit above the factor, and it throws if the two bounds round to different token counts. Recompute that way. An internal review recorded a price difference of about 0.26% between the last curve price and the first market price. The table was left as specified, and a later price is whatever the table says at that state.
Leaf order is every buy, then every sell. Inside each side, the source state runs from low to high and the trade size follows AMM_STEPS, skipping a size that would leave the range -1,610 through 4,607. At 100 bps the tree has 159,698 leaves.
amm-table.json must match makeAmmTable() at every state. An indexer recomputes with integer division.
#Taproot tree
The curve tree and the market tree use the same rules.
- A leaf hash is the tagged hash
TapLeafof version byte0xc0, then the compact size of the script, then the script. A script of 253 bytes or more uses the 3-byte0xfdcompact-size prefix. - A range of
n > 1leaves splits afterfloor(n / 2). The left child is the first half. - A branch hash is
TapBranchof the two child hashes, sorted by bytes. - The output script is
OP_1 OP_PUSHBYTES_32and the tweaked output key. There is no key-path spend. The internal point has no known private key. - The control block is
0xc0with the output-key parity bit, then the internal key, then the sibling hashes on the path. Its length is33 + 32 * depthbytes.
A 9,431-leaf curve tree built with that split has depth 13 or 14, so the control block is 449 or 481 bytes. The market tree is deeper. Its longest control block in the current tests is 609 bytes (33 + 32 * 18). Compute the path. Do not freeze a market control block length into a constant.
Build order for one pearl: GENESIS = commitTxid:0, then the token tree, then the market pool P_a, then the curve pool P_c. Curve leaves put the program of P_a on the change blacklist. The reveal transaction is last. The public id is output 1 of the reveal, not GENESIS.
#State record
Output 0 of every protocol transaction is an OP_RETURN worth 0 grain. The script is 63 bytes: 6a 3d and a 61-byte record. The serialized output prefix is 11 bytes:
00 00 00 00 00 00 00 00 3f 6a 3dThe 61-byte record:
| Offset | Length | Field |
|---|---|---|
| 0 | 4 | Tag 50 52 4c 01 (ASCII PRL, version 1) |
| 4 | 1 | Kind: 00 launch, 01 transfer, 02 pool move, including harvest |
| 5 | 4 | decl0 = AMT(...) |
| 9 | 4 | decl1 = AMT(...) |
| 13 | 20 | Holder of slot 1. An empty slot is 20 zero bytes |
| 33 | 4 | Amount of slot 1. An empty slot is AMT(0) |
| 37 | 20 | Holder of slot 2 |
| 57 | 4 | Amount of slot 2 |
An empty slot is 20 zero bytes and AMT(0) together. A holder id, for a person or for a pool script, is:
HASH160(0x51 0x20 || program32)0x51 0x20 is the P2TR script without its length byte. The market leaves use the same function.
Conservation: decl0 + decl1 = slot1 amount + slot2 amount. The protocol does not burn tokens. On a kind 02 pool move, decl0 is the inventory before the move and slot 1 is the inventory the pool script still holds.
A slot that creates an output must have a holder other than 20 zero bytes and an amount other than AMT(0). On an optional slot 2, the holder is all zeros exactly when the amount is AMT(0). The pairs (all zeros, some tokens) and (a real holder, zero tokens) fail.
#Shared script rules
nVersion = 2. On a pool move and on harvest, every input hasnSequence = 0xffffffff. AbsolutenLockTimeis ground until the covenant challenge fits. It is not a time lock.- The sighash is BIP 341
SIGHASH_DEFAULT. The message hash-type byte is0x00,spend_typeis0x02(script path, no annex),key_versionis0x00, andcodesep_posis0xffffffff. The pool leaf uses input index 0. A token leaf uses its own input index, given below. - The challenge is
e = tagged_hash("BIP0340/challenge", G.x || G.x || m). The signature isR || swithR = Gands = e + 1. The script requires the last bytebofeto satisfy1 <= b <= 127. It ends inCHECKSIG. The spender changesnLockTimeuntilbfalls in that range. The witness carrieseas 31 bytes plus that last byte. The private key is the public value 1 and the nonce is 1, so anyone can compute the same signature. The check binds the transaction that was assembled, because only the leaf's constants produce a message the node will accept. SIZEfollowed byEQUALVERIFYlocks a length. One byte too short or too long fails.- A stack element holds at most 520 bytes. The reconstructed previous transactions
PandPPeach have to fit in one element, so their non-witness serialization is at most 520 bytes.
sha_prevouts, sha_amounts, sha_scriptpubkeys, sha_sequences, and sha_outputs are a single SHA256 of the BIP 341 concatenation, not HASH256. The txid of a reconstructed P or PP is HASH256 (SHA256 twice), then used in internal byte order.
#Curve pool leaves
poolLeaf is the one template. A buy leaf writes decl1 and the sold token amount as constants, and takes the buyer's holder id from the witness. A sell leaf takes decl1, the slot 2 holder, and the slot 2 amount from the witness. Harvest does not use this leaf.
#Buy transaction
f is the number of PRL funding inputs, 1 or 2.
| Index | Input | Output |
|---|---|---|
| 0 | Pool, prevTxid:1, amount C[i], script P_c | Output 0, kind 02 |
| 1 | Inventory, prevTxid:2, 1,000 grain, token script | C[j] paid back to the same P_c |
| 2 | Funding P2TR | Inventory token output, 1,000 grain |
| 3 | Second funding P2TR, only when f = 2 | Platform fee F to the fee address |
| 4 | Buyer token output, 1,000 grain, amount delta = (j - i) * 1,000,000 | |
| 5 | Change P2TR |
The change program must not equal the pool program, the token program, or forbiddenChange. At genesis that blacklist is the market-pool program.
Output 0 is:
TAG || 02 || AMT(Y_i) || AMT(0) || HASH160(0x5120 || prog0) || AMT(Y_j) || buyer || AMT(delta)prog0 is this pool's 32-byte program, read from the witness. The script computes the holder id. The witness does not supply it.
Grain for the change, before the builder's 1,000 grain floor: the funding inputs cover D + F, the extra 1,000 grain of the new buyer output, and the miner fee. The inventory's 1,000 grain goes back out as the new inventory output.
The wallet signs only the funding inputs, index 2, or indexes 2 and 3. buildBuyTx has already ground nLockTime.
#Sell transaction
| Index | Input | Output |
|---|---|---|
| 0 | Pool C[j], prevTxid:1 | Output 0 |
| 1 | Inventory Y_j, prevTxid:2, token leaf PI | C[i] back to P_c |
| 2 | Seller's tokens, amount a >= delta, token leaf PT | Inventory token output |
| 3 | Seller's own P2TR, key-path signature. This input also authorizes PT | Platform fee F for the move j to i |
| 4 | Seller's remaining tokens, amount a - delta, only when a > delta | |
| Last | Change |
A sell always has input 3. There is no form with f = 0. The pool witness still carries f = 2: the first funding item is the seller's token output (1,000 grain, token program) and the second is the seller's PRL. The wallet signs only input 3 (signInputs = [3]). Call buildSellTx.
Slot 2 is optional. A partial sell (a > delta) writes the remaining tokens at output 4 and then the change, six outputs in all. A full sell (a = delta) sets slot 2 to 20 zero bytes and AMT(0), omits output 4, and has five outputs. The spare 1,000 grain from the token input that no longer needs an output is added to the seller's change.
partial change = (C[j] - C[i] - F) + funding - miner fee
full change = (C[j] - C[i] - F) + funding + 1,000 - miner feeThe builder rejects a change below 1,000 grain.
#Witness
poolWitness is the only order. Bottom of the stack to top, without the leaf script and the control block:
e31 || b || lockTime || leafHash
|| changeAmount8 || changeProgram32
|| [decl1_4] [owner2_20] [amount2_4] # only fields marked witness
|| prevTxid32 || prog0_32
|| [prevout36 || amount8 || program32] # when f = 2, input 3 first, then input 2
|| f # one byte, 1 or 2A buy's slot witness is only the 20-byte buyer holder id. A sell's slot witness is decl1, the seller's holder id, and AMT(a - delta).
#What the leaf checks
The buy script compiled from the default table is 754 bytes. The sell script is 776 bytes. Both figures are the script only, with sample 32-byte programs, and they do not include the control block. [[n]] below means SIZE n EQUALVERIFY. Concatenation consumes the stack from the right, as the template is written.
- Funding count.
DUP 1 3 WITHIN VERIFY TOALTSTACK.fis 1 or 2. - The first funding input, which is transaction input 2.
[[32]], then the prefix22 51 20, then[[8]], then[[36]]. That builds the script, the amount, and the outpoint. - When
f = 2, do the same for input 3 and append both triples. - Sequence hash. Every
nSequenceisffffffff. The script builds 12 bytes whenf = 1and 16 bytes whenf = 2, thenSHA256. It does not read sequences from the witness. sha_prevouts = SHA256(prevTxid || 01000000 || prevTxid || 02000000 || the funding outpoints).prevTxidandprog0are each[[32]]. The inventory must be output 2 of the same transaction as the pool.sha_amounts = SHA256(le64(C_s) || le64(1000) || the funding amounts).C_sis a leaf constant.sha_scriptpubkeys = SHA256(22 51 20 || prog0 || the 35-byte token script || the funding scripts).- Witness fields of output 0 are checked at 4 or 20 bytes.
DUP 51 20 SWAP CAT HASH160is the pool's holder id. - Assemble output 0: prefix, tag, kind
02,AMT(Y_s),decl1, holder id,AMT(Y_t), slot 2. - The change program is
[[32]]and must differ fromprog0, the token program, and each blacklisted program. The change amount is[[8]]. - Hash the outputs: output 0, then
le64(C_t) || 22 51 20 || prog0, then the inventory token output, then the platform fee when there is one, then the trader token output when slot 2 is used, thenchangeAmount || 22 51 20 || changeProgram. A buy pushes the token output once and duplicates it, so the 43-byte constant is not pushed twice. An optional slot 2 skips the trader output when the witness slot is empty. - Sighash and
CHECKSIG, as in the shared rules.G.xis pushed once and duplicated.
#Token leaves
There are 24 leaves. allTokenRoles() fixes the tree order.
| Role | Count | What it spends | Who authorizes it |
|---|---|---|---|
T(m, k, t, prev) | 12 | A transfer. m is 1 or 2 authorizing inputs. k is this input's index, 0 or 1, and k < m. t is 1 or 2 token outputs. prev is X or P | The holder's 32-byte output key Q, inside this leaf |
PI(m, t, prev) | 8 | The inventory, always input 1. prev is L or P | Input 0, the pool leaf, which has already checked the pool |
PT(t, prev) | 4 | The trader's tokens, always input 2. prev is X or P | The holder's output key Q, inside this leaf |
prev = L means the tokens were born in the launch (kind 00). The script hard-codes the 36-byte GENESIS. X means the previous transaction was a transfer (kind 01). P means it was a pool move (kind 02).
witnessNames lists the items a role may need. The stack order is the order chosen by compileLeaf for that leaf. A wallet must pack the witness with tokenLeaf(role, genesis).order. Naming the items w0 through w12 in some other order will not spend.
#Checks every leaf makes
- Holder fields and amount fields have the right length. An amount is
WITHINthe 4 bytes ofAMT(0)inclusive andAMT(1,000,000,000) + 1exclusive. - Unless the source is the launch, rebuild the earlier transaction
PP(at most 4 inputs and 3 intermediate P2TR outputs) andHASH256it to a txid. An empty outpoint or amount slot takes no space. A used slot is a 36-byte outpoint or an 8-byte amount plus a 35-byte P2TR output. - Rebuild
P, the transaction that created this token: version, input count, inputs (a launch source's input 0 must be the hard-codedGENESIS), the opaque remainderPinRest, output count, output 0, andPtail.HASH256isP's txid. This input's outpoint must name that txid and the declared output index. - On a transfer, the token may sit in slot 1 or slot 2. A transfer source uses output 1 or 2. A pool-move source uses output 2 or 4. Inventory is always output 2, which is slot 1.
sha_prevoutscovers this token input and every input before it in the same transaction.- Authorization. For
TandPT,HASH160(0x51 0x20 || Q) = myOwner, andQsigns this leaf with a 64-byteSIGHASH_DEFAULTsignature (CHECKSIGVERIFY). That signature commits to the whole transaction. ForPI,HASH160(0x51 0x20 || program of input 0) = myOwner. The pool leaf on input 0 is what authorizes the inventory. decl0 + decl1 = amount1 + amount2.- Assemble output 0 and
sha_outputs. The current transaction's outputs are fully listed: the token outputs the role allows, the pool and fee outputs a pool move requires, and exactly one P2TR change at the end. The change program must not be the token program. On a pool move it also must not be the pool program. An extra output fails.Ptailbelongs to the previous transaction being rebuilt, and it is checked by length as part of that reconstruction. - The sighash input index is
kfor a transfer, 1 for inventory, and 2 for the trader's tokens. The version is the constant 2. The current transaction's sequences are the constantffffffff, assembled in the script.nLockTimeand the leaf hash come from the witness.
To follow one token, walk P and then PP until kind 00, and require that kind 00 spends this pearl's GENESIS as input 0. A pool move's inventory input uses PI. Tokens the seller returns use PT.
A launch-source inventory leaf also checks the reveal outputs it was compiled with: output 1 pays C[0] to the pool program, output 2 is the 1,000 grain inventory, and output 3 pays the launch fee to the fee program.
#Launch
| Name | Value |
|---|---|
GENESIS | commitTxid:0. Leaves with prev = L hard-code this |
tokenId | revealTxid:1. This is the curve pool output, and it is the id an indexer and a URL use |
genesisOutpoint | The same outpoint as GENESIS, stored on Token.genesisOutpoint |
#Commit
The commit is version 2. Its input is the creator's ordinary P2TR, spent by a key-path signature.
Output 0 is a script-path address under the unspendable internal point. Its leaf is the inscription. The amount is C[0] + 1,000 + launch fee + the reveal's miner fee.
Output 1 is an optional change. Below 333 grain it is left off. The commit itself is not a protocol event.
The inscription leaf is:
<creator public key> CHECKSIG
OP_0 IF
50 52 4c 01
OP_1
<mime>
OP_0
<chunks>
ENDIFEach chunk is 1 through 520 bytes, and every chunk except the last is exactly 520. The chunks concatenate to le32(metadata length) || UTF-8 JSON || image bytes. The JSON is {"meta": TokenMeta, "tradeFeeBps": n}. The parser accepts tradeFeeBps from 1 through 10,000. The platform indexes 100 only, as specified above.
The image is png, jpeg, webp, or gif, and the launch builder rejects a file larger than 30,000 bytes (LAUNCH_IMAGE_MAX_BYTES). The shared metadata schema names a larger image cap. The builder's 30,000 byte cap is the one that constructs a launch. A name is at most 32 characters, a symbol is 2 to 10 characters from A-Z and 0-9, and a description is at most 280 characters. Metadata JSON is at most 6,000 bytes.
#Reveal
Input 0 spends output 0 of the commit through the inscription leaf. There is no key-path spend. The first four outputs are the launch layout. The launch-fee amount is the launchFee the caller passed. The layout constant used by the checks is 5 PRL.
| Output | Contents |
|---|---|
| 0 | Kind 00. Both declarations are AMT(0). Slot 1 is the pool program's holder id and AMT(1,000,000,000). Slot 2 is empty |
| 1 | C[0] to P_c. This output is tokenId |
| 2 | 1,000 grain to the token script. This is the inventory of 1,000,000,000 tokens |
| 3 | Launch fee to the platform P2TR |
The reveal's non-witness serialization must be at most 520 bytes, because the next buy's PI with prev = L rebuilds the whole transaction inside one stack element. There is no fifth change output. Extra grain stays in the commit.
checkGenesis also requires version 2, 1 through 4 inputs, input 0 equal to GENESIS, every nSequence equal to ffffffff, and at most 5 outputs. That describes a transaction that spends GENESIS directly. On the inscription path, the transaction that meets those checks is the reveal, not the commit.
estimateLaunch sizes the two transactions as:
base = 8 + CompactSize(input count) + 41 * input count + CompactSize(output count) + output bytes
vB = ceil((base * 4 + 2 + witness bytes) / 4)
commit witness bytes = input count * 66
reveal witness bytes = 1 + 65 + CompactSize(leaf length) + leaf length + 34A commit with no change has a 43-byte output. A commit with change has 86 bytes of outputs. The reveal estimate uses 72 + 3 * 43 output bytes. Leaf length is 45 + mime length + body + push overhead. The body is 4 + metadata + image. Each full 520-byte chunk adds a 3-byte push header, and the last chunk uses a 1-byte header up to 75 bytes or a 2-byte header up to 255.
#Harvest
The only leaf that can spend C[800] is graduationLeafScript. Anyone can build the transaction. The funding inputs pay the miner fee. There is no platform-fee output.
| Index | Input | Output |
|---|---|---|
| 0 | Curve pool, prevTxid:1, amount C[800] | Output 0, kind 02, a constant |
| 1 | Inventory, prevTxid:2, leaf PI | C[800] to P_a, a constant |
| 2 | One or two funding P2TR inputs | Inventory token output. The holder is the holder id of P_a. The amount is 200,000,000 tokens. Both are constants |
| Last | Change. It must not pay P_c, the token script, or P_a |
Outputs 0, 1, and 2 are the leaf constant graduationFixedOutputs. In output 0, decl0 and the slot 1 amount are both AMT(200,000,000). decl1 and slot 2 are empty. The slot 1 holder is HASH160(0x5120 || P_a).
Witness, bottom to top, from poolWitness with no slot fields:
e31 b lockTime leafHash | changeAmount changeProgram | prevTxid | prog0 | [p3 a3 g3] p2 a2 g2 | fThe input-side opcodes match poolLeaf byte for byte. The script consumes the funding inputs, builds the sequence hash from 12 or 16 bytes of 0xff, starts sha_prevouts at prevTxid:1 || prevTxid:2, starts the amount hash at C[800] || 1000, starts the script hash at P_c || token script, rejects a change paid to any of the three programs, hashes the three constant outputs plus the change, then checks the sighash.
Input 0 is finalized by the harvest leaf. Input 1 is finalized by PI(1, 1) with prev = P. Funding inputs are left for the wallet. signInputs starts at 2. Call buildGraduateTx.
#Market trades
A market leaf is poolLeaf with the market table's constants: C_s becomes X_s, C_t becomes X_t, and Y_s, Y_t, and F come from the transition. A buy leaf matches a curve buy: decl1 = AMT(0), the slot 2 amount AMT(Y_s - Y_t) is constant, and the buyer's holder id comes from the witness. A sell leaf matches a curve sell: decl1 and slot 2 come from the witness, and slot 2 is optional, so selling the whole amount does not create output 4. The one constant that differs is forbiddenChange, which is empty, because a market leaf does not know P_c. The function is ammLeafScript. A buy script is 717 bytes and a sell script is 739 bytes. The tree has 159,698 leaves, and the longest control block in the current tests is 609 bytes.
| Index | Input | Output |
|---|---|---|
| 0 | Market pool, prevTxid:1, amount X_s | Output 0 |
| 1 | Inventory, prevTxid:2. A buy uses PI(1, 2, P). A sell uses PI(2, t, P) | X_t back to the same market pool |
| 2 | Buy: funding P2TR. Sell: the seller's tokens, PT(t, X or P) | Inventory token output |
| 3 | Buy: optional second funding input. Sell: the seller's own P2TR, required | Platform fee F |
| 4 | Trader token output. Always present on a buy. Present on a sell only when slot 2 is not empty | |
| Last | One P2TR change |
Output 0 is TAG || 02 || AMT(Y_s) || decl1 || HASH160(0x5120 || pool program) || AMT(Y_t) || slot2. The trader's holder id is HASH160(0x5120 || trader program), the same function as the token leaves.
poolWitness builds the witness in the same order as the curve. The constructor is buildAmmSwapTx. It grinds nLockTime together with the token leaves. The PT signature is token.holderSign when the caller passes it. Otherwise the result lists pendingSignatures and the wallet fills them in. The wallet signs the funding inputs only.
#What is not in the protocol
The implemented protocol has no order-book leaf, no SIGHASH_SINGLE | ANYONECANPAY listing, and no on-chain order id. The design note that described a LIST transaction was withdrawn. After harvest, the secondary market is the pool in the previous section.
An indexer must not treat "a token output plus a partial signature" as an order. A wallet that wants to sell calls buildSellTx on the curve or buildAmmSwapTx on the market.
#Measured size
Virtual size is ceil(weight / 4), with weight = non-witness bytes * 3 + total bytes including the witness. The table is the local test chain run in the end-to-end report. In that run the miner fee is 3 grain per vB, so each miner-fee cell is the virtual size times 3. That rate was chosen for the run. The script does not fix it. A builder that disagrees with testmempoolaccept should trust the node.
| Transaction | vB | Platform fee |
|---|---|---|
| Launch commit | 154 | 0 |
| Launch reveal | 328 | 500,000,000 grain (5 PRL) |
| Curve buy | 1,214 | 1,922,181 grain |
| Curve buy | 1,411 | 4,836,949 grain |
| Transfer | 890 | 0 |
| Curve sell | 2,200 | 1,940,204 grain |
| Curve fill, sixteen transactions | 1,453 to 1,471 | per transaction in the report |
Harvest, one funding input, PI(1, 1, P) | 1,336 | 0 |
| Market buy | 1,454 | 6,003,907 grain, then 3,006,455 grain |
| Market sell | 2,194 | 3,006,455 grain |
| Market sell | 2,187 | 3,003,459 grain |
The report lists every txid. Curve sells in that run and in the earlier local run sit above 2,000 vB and under the 3,000 vB cap. Most of the witness on a sell is PI and PT rebuilding P and PP.
Commit and reveal size moves with the image and the input count. Use estimateLaunch for a quote, then the node's virtual size for the transaction you will broadcast. A pool move the constructor measures above 3,000 vB throws before it is returned.
#What an indexer and a wallet check
An indexer does all of the following.
- Recognize the reveal as in the launch section.
tokenIdisreveal:1.GENESISis input 0 of that reveal. - Recompute
C[step]and the market table from the formulas above. The PRL in the pool is enough to name the curve layer or the market state. - Parse the 61 bytes in output 0. The harvest is the kind
02transaction whose pool script changes fromP_ctoP_a. - Follow token balances along
PandPP. Do not trust a holder id in output 0 unless the authorizing input or the in-leaf signature matches. Market slot 2 uses the same holder function as every other leaf. - Keep unconfirmed spends of one pool in a single chain. Input 0 of each transaction is output 1 of the previous one, and input 1 is output 2 of the previous one.
- Index a launch only at 100 bps, and only when the launch fee matches the canonical value. Record any other rate as rejected, not as a pearl.
A wallet does all of the following.
- Buy on the curve with
buildBuyTx. Sign only the funding inputs, index 2, or indexes 2 and 3.nLockTimeis already ground. - Sell on the curve with
buildSellTx. Sign only input 3. - Trade on the market with
buildAmmSwapTx. Sign only the funding inputs. The seller's token input is finalized byPT. - Transfer with
buildTransferTx. The authorizing input needstapInternalKey, andTorPTneeds the holder's 64-byte signature. - Do not send change to
P_c,P_a, or the token script. The 1,000 grain on a token output is not spendable as ordinary PRL. PRL sent straight to a pool or token script can only move if some leaf pays it out, and these leaves do not.
#Next
The numbers in the size table are copied from the end-to-end report. Recompute the reserves from curve-params.json and the market states from amm-table.json, then check each file's SHA-256 against this page.