Skip to content

03 · From an intention to Bitcoin bytes

Start with a task: issue a fixed-supply asset, pay one recipient or distribute one asset to several recipients. A wallet or Agent can express the asset, amounts and recipient outputs through the same public SDK, then pass the prepared transaction to the wallet for review and signature.

Task: issue or transfer an asset
  ↓
Public SDK: encode the instruction
  ↓
Wallet: construct, review and sign
  ↓
Bitcoin confirms the transaction
  ↓
Indexer applies the asset rules

This chapter follows that task into the exact bytes. Begin with the runnable examples to try it, then use the fields and checks below to build an integration.

A compact instruction inside a Bitcoin transaction

AIBRC instructions are carried in an OP_RETURN data push in a Bitcoin transaction output. The marker bytes are 41 49 42 52, ASCII AIBR. An interpreter does not search arbitrary witness data, annotations or non-OP_RETURN outputs for text that changes asset state.

Instruction discovery · Live

Extraction of one complete AIBRC marker from actual outputs, with checks on push structure and payload boundaries. Independent implementations share the same definition of an instruction.

Writing “AIBRC” somewhere in a transaction does not authorize an asset transfer.

OP_RETURN → minimal data push → AIBR header → one instruction.

No marker means no AIBRC state change. Two or more recognized markers make the AIBRC effects of the transaction a no-op with DUPLICATE_STATE_INSTRUCTION. Recognizable malformed markers participate in duplicate counting: an interpreter must not discard one and then accept another. See §2 of the specification and the public extractor.

The first nine payload bytes are:

magic       version network opcode body_length
41 49 42 52 | 01   | byte  | byte | u16be

Fixed-width integers are big-endian. Transfer receiver indexes and amounts use the shortest unsigned LEB128 representation; a longer encoding of the same integer is invalid. See §§1, 3 and 5.

Deploy: one issuance, a fixed supply

Fixed-supply issuance · Live

An explicit deployment authorization input, initial owner output, name and total supply. The deployment initiator and initial asset recipient can be distinct participants.

You can initiate an issuance while explicitly assigning the initial assets to another script account.

auth_input:u16 + owner_output:u16 + name_length:u8 + name + supply:u128.

The rules are in §§4 and 4.1. Deploy does not grant an additional issuance operation; the current core has no separate Mint opcode.

The core SDK call is shown below. It uses the shared imports and context; the complete deployment file runs independently.

const payload = encodeDeploy({
  network, name: 'DEMO',
  totalSupply: 1_000_000n * UNIT,
  deployAuthInputIndex: 0, ownerOutputIndex: 1,
}, namePolicy);

These bytes come from deploy-valid-01 in the official operation vectors. This is a Signet offline test case, not a broadcast transaction or a Mainnet issuance record.

41494252010201001600000001014100000000000000000000000000000001

The fields are:

41494252  AIBR
01        wire version 1
02        Signet
01        Deploy
0016      body length: 22 bytes
0000      authorization input 0
0001      initial owner output 1
01 41     name length 1; name A
00000000000000000000000000000001
          total supply: 1 base unit

Decoded fields (JSON view, not the wire payload):

{
  "kind": "DEPLOY",
  "version": 1,
  "network": 2,
  "deployAuthInputIndex": 0,
  "ownerOutputIndex": 1,
  "name": "A",
  "totalSupply": "1"
}

Decoding these bytes does not establish a valid deployment. Execution also needs the actual authorizing input and owner output, the applicable name policy, supported scripts and sighash, a valid supply, and a name not already claimed by an earlier valid Deploy. Only then does the operation create the asset and credit its owner.

To generate an instruction with the SDK, run node examples/deploy.mjs after building the repository. The runnable deployment example shows the complete call to encodeDeploy, including its name-policy context.

Raw payload
  ↓ decode
Deploy fields
  ↓ check transaction context and pre-state
  ├─ Valid → asset, name and initial balance created
  └─ Invalid → NO_OP; protocol state unchanged

Transfer: several allocations of one asset

Single-asset batch transfers · Live

One sender can allocate one asset through up to 25 allocation entries in one instruction. Several payments can share a Bitcoin transaction without becoming several independent AIBRC instructions.

State who receives how much; if one required allocation is invalid, none is applied.

auth_input + allocation_count + asset_locator + (output_index, amount)[].

One receiver uses one allocation; a batch adds further entries. This excerpt uses the shared setup.

const payload = encodeTransfer({
  network, authInputIndex: 0,
  assetLocator,
  allocations: [
    { receiverOutputIndex: 1, amount: 10n * UNIT },
    { receiverOutputIndex: 2, amount: 20n * UNIT },
    { receiverOutputIndex: 3, amount: 30n * UNIT },
  ],
});

See §§5–6. The complete byte limit also applies, so 25 arbitrary large amounts are not guaranteed to fit a particular broadcast profile.

The same vector file includes sixRecipientCompatibilityVector, a 30-byte payload:

414942520102020015000006000cd1400007010a0214031e04280532063c

It specifies Signet, Transfer, authorization input 0 and the asset deployed at height 840000, original transaction index 7. Outputs 1–6 receive 10 / 20 / 30 / 40 / 50 / 60 base units. The checked total is 210, which the sender must hold before execution. See §§5 and 7.

Run node examples/transfer-single.mjs for one recipient, or node examples/transfer-batch.mjs 25 for 25. The batch-transfer example accepts every count from 1 through 25 and shows how each amount binds to an actual output index. These files generate payloads; the Bitcoin transaction also needs the corresponding receiver outputs.

To read an instruction back, use the decoder example: node examples/decode.mjs <payload-hex>.

Declared authorization input
  ↓ derive sender script account
Canonical asset locator
  ↓ resolve asset ID
Actual receiver outputs and amounts
  ↓ validate all fields
Debit total; apply receiver credits

A BTC output value is not an AIBRC amount. Satoshis assigned to an output belong to the Bitcoin transaction; base units assigned by Transfer belong to the protocol instruction. An interface should explain both without substituting one for the other.

Invalid instructions: no state effect, a clear explanation

Deterministic rejection · Live

Stable outcomes for malformed data, wrong networks, unknown versions, unsupported authority and invalid balances. Wallets and indexers can distinguish an invalid operation from a rule version they must understand before proceeding.

Bitcoin confirmation records the transaction; a valid AIBRC instruction determines its asset effects.

APPLIED / NO_OP / NEEDS_UPGRADE + stable reason code.

NO_OP means the AIBRC instruction has no state effect. It does not reverse a BTC payment in the same transaction or refund miner fees. NEEDS_UPGRADE requires retaining the previous verified state rather than reporting current balances after skipping an activated rule the implementation does not understand. See §§8–9.

Condition Protocol outcome Meaning for an integration
No AIBRC marker NO_OP / NOT_AIBRC An ordinary BTC transaction does not automatically move protocol assets
Wrong network NO_OP / UNKNOWN_NETWORK Do not apply state across networks
Malformed amount or boundary NO_OP / corresponding format code Do not partially allocate
Unsupported script or sighash NO_OP / corresponding authority code A valid BTC spend need not satisfy AIBRC authorization
Insufficient asset balance NO_OP / INSUFFICIENT_BALANCE The transaction may confirm without delivering this asset
Activated but unimplemented version NEEDS_UPGRADE Do not advance the verified height past that block

The complete codes are in reason codes.

Payload limits and broadcast profiles

The complete protocol payload is limited to 480 bytes. The default Compatibility Profile is at most 80 bytes. Exceeding the compatibility threshold does not necessarily make an instruction invalid, and protocol validity does not mean every relay will forward it. Check the chosen node's policy against the exact transaction. See §§1 and 1.1.

Splitting belongs to construction and explicit authorization. A builder cannot silently replace one signed transaction with several new ones. Repeatedly sending the same rejected bytes does not establish that relay policy has changed.

Where extensions belong

Delegation, multi-asset transfers, locks, bindings, attestations, checkpoints and conditional transfers are not current Deploy/Transfer semantics. Their purposes, format directions, validity rules, state effects and open questions are in the proposal directory. A reserved opcode band alone creates none of those capabilities.