Partial Coloring / Custom Coloring

Describe the implementation detail of Particial Coloring / Custom Coloring of Atomicals and how to integrate with these features.

New coloring features are introduced with Atomicals ElectrumX v.1.5.0 and could be activated at the block height 848484 on the livenet (2584936 on the testnet).

The runnable code should be based on the v1.5.* tags. See the API Integration Guide for the migration guide for the breaking change.

Partial Coloring

The partial coloring ability allows Atomicals value to be divided less than 546 without burning in some cases. The user has no direct interaction with the feature because it is a subset of the Atomicals Transfer Rules. Here are some transaction cases that would not burn the Atomicals:

Fully colored -> Partially colored

Input/Output
Satoshis
Atomicals

vin:0

1000

1000 ATOM

vin:1

9900

0 ATOM

vout:0

900

900 ATOM

vout:1

10000

100 ATOM

When the transaction is trying to assign 900 ATOM to the vout:0, 100 ATOM is left which results in burning without the feature. Now, with the partial coloring, the transaction should try to assign the 100 ATOM to the vout:1, and it can since sats_value >= atomical_value.

Input/Output
Satoshis
Atomicals

vin:0

1000

1000 ATOM

vin:1

546

0 ATOM

vout:0

999

999 ATOM

vout:1

547

1 ATOM

Here is another example of the coloring. If you want to split 1 ATOM (or 999 ATOM) from the vin:0, assign the 1 ATOM to vout:1. The vout:1 could be 546 sats too since its sats_value >= atomical_value.

Partially colored -> Fully colored

Input/Output
Satoshis
Atomicals

vin:0

1000

100 ATOM

vin:1

1000

900 ATOM

vout:0

1000

1000 ATOM

vout:1

1000

0 ATOM

With 2 partially colored UTXOs, assigning them to one specific output will be done automatically.


Custom Coloring

The custom coloring ability allows Atomicals value to be separated less than 546 by introducing the z operation. The value is without decimals and should follow the normal transfer rules.

Notice of the operation

z is powerful, but it should be only used in certain cases to avoid more gas during transactions. Here are some notices about the z.

  1. Use it only when the Atomicals value in all outputs is less than 546, or it could lead to extra size compared to a normal transfer transaction (cleanly assigned).

  2. The coloring value must not be greater than the satoshis value of the UTXO, coloring values greater than the satoshis value will be reset to the satoshis value, and the remaining values will be burned.

Main Steps

To send a custom coloring transaction, you shall follow these instructions:

  1. Put z as the OP code in HEX (7a).

  2. Put the desired colored Atomicals value records into the payload. The record should follow the structure (in TypeScript): Record<string, Record<number, number>>.

  3. Gather UTXOs to back coloring values, and make sure each UTXO has sat_value >= atomical_value.

An example payload could be:

The payload indicates that the ARC-20 with ID 9527... should have 1000 in the vout:0, and 2000 in the vout:1. And the ARC-20 with ID 8888... should have 3000 in the vout:2, and 4000 in the vout:3.

Split merged assets

Since the operation can define where Atomicals go, the z operator can be considered as the advanced version of x (splat) + y (split), their operations can be done during custom coloring in one single z transaction. Developers should choose between these operations according to use cases.

Custom coloring code example

View the full code example.

How to sign reveal psbt

Decoding Transactions

To know the exact coloring result of a PSBT or a raw transaction, use /proxy/blockchain.atomicals.decode_psbt to decode a PSBT or /proxy/blockchain.atomicals.decode_tx to decode a raw transaction HEX string. These methods were added since v1.5.0 patch 2.

Last updated