A new transaction structure allows to include multiple commands into one transaction. This is done by including a list of commands in the transaction payload. Each command is executed one by one and may be invalid without invalidating the other commands.
The payload structure may look like this:
[transaction marker] [number of commands] [command 1] ( [command 2] [...] )
In combination with multi-command payloads using this command allows to send multiple tokens to multiple recipients from multiple sources.
It transfers all tokens associated with the transaction inputs to the specified receivers of the transaction. Note that this is very different from regular simple sends, because all incoming tokens are transferred and tokens are bound and attached to outputs instead of addresses. As consequence, the available tokens for the transfer are implicitly given by the transaction inputs, which were previously outputs of an earlier transaction.
Any leftover amount of tokens that is not explicitly transferred is burned [1].
A single transfer command has the following structure:
Field | Type | Example |
---|---|---|
Command type | Command type | 1 |
Receiver output # | Number | 3 |
Token identifier | Token identifier | 1 (= Omni) |
Token amount | Number of tokens | 1 0000 0000 (= 1.0) |
[1] Alternative:
The leftover tokens might as well be transferred to the miner, but then "the miner" needs to be specified: is it the first output of the coinbase transaction? What if there are mulitple coinbase outputs, e.g. in case of P2Pool?
Let's imagine a transaction with three inputs and four outputs. Bitcoin values are omitted in this example, but we simply assume the amount of incoming coins is enough to cover the whole transaction.
Each input has tokens associated with it:
Input Index | Token identifier | Token amount |
---|---|---|
0 | 1 (Omni) | 1 5000 0000 (= 1.5) |
1 | 31 (TetherUS) | 50 0000 0000 (= 50.0) |
2 | 1 (Omni) | 3 0000 0000 (= 3.0) |
The total amounts of tokens flowing into this transaction are therefore 4.5 Omni and 50.0 TetherUS.
The outputs of the transaction are as follows:
Output Index | Script type |
---|---|
0 | Payload with commands |
1 | Pay-to-pubkey-hash (recipient 1) |
2 | Pay-to-pubkey-hash (recipient 2) |
3 | Pay-to-script-hash (recipient 3) |
The first output of the transaction contains the payload with the following data:
Field | Value |
---|---|
Transaction marker | 0x6f6c (= "ol") |
Number of commands | 3 |
Command type | 1 |
Receiver output # | 3 |
Token identifier | 1 (= Omni) |
Token amount | 4 5000 0000 (= 4.5) |
Command type | 1 |
Receiver output # | 1 |
Token identifier | 31 (= TetherUS) |
Token amount | 20 0000 0000 (= 20.0) |
Command type | 1 |
Receiver output # | 2 |
Token identifier | 31 (= TetherUS) |
Token amount | 30 0000 0000 (= 30.0) |
4.5 Omni are transferred to the transaction output with index 3, 20.0 TetherUS are transferred to the transaction output with index 1, and 30.0 TetherUS are transferred to the transaction output with index 2.
@dexX7 How to create a transaction by this way? can it specify recipients address?