0

I'm studying open asset protocol, however I have no idea how to read asset quantity list.

The Open Assets Protocol documentation tells that data in marker output

0xac 0x02 0x00 0xe5 0x8e 0x26

means

The asset quantity list:
                                   - '0xac 0x02' means output 0 has an asset quantity of 300.
                                   - Output 1 is skipped and has an asset quantity of 0
                                     because it is the marker output.
                                   - '0x00' means output 2 has an asset quantity of 0.
                                   - '0xe5 0x8e 0x26' means output 3 has an asset quantity of 624,485.
                                   - Outputs after output 3 (if any) have an asset quantity of 0."

Could you tell me how they calculate quantity of assets by the marker output? I thought that 0xac is 13(c)*16^0 + 10(a)*16^1 = 173, but it seems the idea is not correct.

2

According to the Open Assets Protocol Spec, the amounts are encoded in something called the unsigned LEB128 encoding. So for 300 the binary looks like:

100101100

You have to pad to a multiple of 7 (we have 9 bits, so this becomes 14):

00000100101100

Now split into groups of 7:

0000010 0101100

Add in a 0 bit for the very first one, and 1 for every other group of 7:

00000010 10101100

In hex, this is:

0x02 0xac

Put this in Little Endian order:

0xac 0x02

You can do the same for the 624,485 number and get the 0xe5 0x8e 0x26.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.