Skip to content

Commit 96f9b06

Browse files
authored
standardize asset introspection with canonical asset id (#97)
1 parent 1f0a246 commit 96f9b06

6 files changed

Lines changed: 476 additions & 199 deletions

File tree

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,22 @@ These opcodes allow incremental SHA256 hashing by maintaining hash state on the
357357

358358
### Asset Introspection Opcodes
359359

360-
These opcodes provide access to the Arkade Asset V1 packet embedded in the transaction. Asset IDs are represented as two stack items: (txid32, gidx_u16).
360+
These opcodes provide access to the Arkade Asset V1 packet embedded in the transaction.
361+
362+
An **Asset ID** is the canonical, position-independent identity of an asset. It is represented as two consecutive stack items, `asset_txid asset_gidx`, where `asset_txid` (32 bytes) is the asset's issuance transaction ID and `asset_gidx` is the group index at which the asset was issued (a minimally encoded ScriptNum in `0..65535`). For a fresh issuance the Asset ID is `(this transaction's ID, k)`, where `k` is the group's position in this packet.
363+
364+
`k` is reserved throughout for a **current packet group position** — the index of a group in this transaction's packet. It is distinct from `asset_gidx`: the two coincide only for fresh issuances. Use `OP_FINDASSETGROUPBYASSETID` to convert a canonical Asset ID into the `k` consumed by the structural per-group opcodes.
365+
366+
An intent input's source transaction ID is **not** an Asset ID; it is available through `OP_INSPECTASSETGROUP` and is never emitted or matched by the canonical opcodes.
361367

362368
#### Packet & Groups
363369

364370
| Word | Opcode | Hex | Input | Output | Description |
365371
|------|--------|-----|-------|--------|-------------|
366372
| OP_INSPECTNUMASSETGROUPS | 229 | 0xe5 | Nothing | K | Returns the number of asset groups in the packet. |
367-
| OP_INSPECTASSETGROUPASSETID | 230 | 0xe6 | k | txid32 gidx_u16 | Returns the Asset ID of group k. Fresh groups use this transaction's ID. |
368-
| OP_INSPECTASSETGROUPCTRL | 231 | 0xe7 | k | -1 or txid32 gidx_u16 | Returns the control Asset ID if present, else -1. |
369-
| OP_FINDASSETGROUPBYASSETID | 232 | 0xe8 | txid32 gidx_u16 | -1 or k | Finds group index by Asset ID, or -1 if absent. |
373+
| OP_INSPECTASSETGROUPASSETID | 230 | 0xe6 | k | asset_txid asset_gidx | Returns the canonical Asset ID of packet group k. Fresh groups use this transaction's ID and k. |
374+
| OP_INSPECTASSETGROUPCTRL | 231 | 0xe7 | k | control_asset_txid control_asset_gidx 1, or empty_bytes 0 0 | Returns the canonical Asset ID of the control asset and a success flag, or `empty_bytes 0 0` when absent. References stored by packet group index are resolved to their canonical Asset ID. |
375+
| OP_FINDASSETGROUPBYASSETID | 232 | 0xe8 | asset_txid asset_gidx | k 1, or 0 0 | Converts a canonical Asset ID to its current packet group position k with a success flag, or `0 0` when the Asset ID is not in the packet. |
370376

371377
#### Metadata
372378

@@ -392,13 +398,13 @@ These opcodes provide access to the Arkade Asset V1 packet embedded in the trans
392398
| Word | Opcode | Hex | Input | Output | Description |
393399
|------|--------|-----|-------|--------|-------------|
394400
| OP_INSPECTOUTASSETCOUNT | 237 | 0xed | o | n | Returns number of asset entries assigned to output o. |
395-
| OP_INSPECTOUTASSETAT | 238 | 0xee | o t | txid32 gidx_u16 amount | Returns t-th asset at output o. Amount is pushed as a BigNum. |
396-
| OP_INSPECTOUTASSETLOOKUP | 239 | 0xef | o txid32 gidx_u16 | amount or -1 | Returns amount of asset at output o, or -1 if not found. Amount is pushed as a BigNum. |
401+
| OP_INSPECTOUTASSETAT | 238 | 0xee | o t | asset_txid asset_gidx amount | Returns the canonical Asset ID and amount of the t-th asset entry at output o. `asset_gidx` is the issuance group index, directly consumable by OP_INSPECTOUTASSETLOOKUP. Amount is pushed as a BigNum. |
402+
| OP_INSPECTOUTASSETLOOKUP | 239 | 0xef | o asset_txid asset_gidx | amount 1, or 0 0 | Returns the amount of the asset with the given canonical Asset ID at output o and a success flag, or `0 0` when absent. Amount is pushed as a BigNum. |
397403

398404
#### Cross-Input (Packet-Declared)
399405

400406
| Word | Opcode | Hex | Input | Output | Description |
401407
|------|--------|-----|-------|--------|-------------|
402408
| OP_INSPECTINASSETCOUNT | 240 | 0xf0 | i | n | Returns number of assets declared for input i. |
403-
| OP_INSPECTINASSETAT | 241 | 0xf1 | i t | txid32 gidx_u16 amount | Returns t-th asset declared for input i. Amount is pushed as a BigNum. |
404-
| OP_INSPECTINASSETLOOKUP | 242 | 0xf2 | i txid32 gidx_u16 | amount or -1 | Returns declared amount for asset at input i, or -1 if not found. Amount is pushed as a BigNum. |
409+
| OP_INSPECTINASSETAT | 241 | 0xf1 | i t | asset_txid asset_gidx amount | Returns the canonical Asset ID and amount of the t-th asset entry declared for input i. `asset_txid` is always the issuance transaction ID, never an intent input's source txid. Amount is pushed as a BigNum. |
410+
| OP_INSPECTINASSETLOOKUP | 242 | 0xf2 | i asset_txid asset_gidx | amount 1, or 0 0 | Returns the declared amount for the asset with the given canonical Asset ID at input i and a success flag, or `0 0` when absent. An intent input's source txid is never accepted as the Asset ID. Amount is pushed as a BigNum. |

0 commit comments

Comments
 (0)