Skip to content

Instantly share code, notes, and snippets.

@dexX7
Last active May 28, 2020 07:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dexX7/ba45d52d8edd084357253d93360e1519 to your computer and use it in GitHub Desktop.
Save dexX7/ba45d52d8edd084357253d93360e1519 to your computer and use it in GitHub Desktop.
Omni Lite

Multi-command transactions

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] [...] )

Transfer command

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?

Example: many-to-many transactions

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.

visualized

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.

Token types

Four types of tokens can be created:

  • Fungible token with fixed supply
  • Fungible token with dynamic supply
  • Non-fungible token with fixed supply
  • Non-fungible token with dynamic supply

Fungible token with fixed supply

Properties:

  • name
  • symbol
  • info

Operations:

  • transfer

Information:

  • get properties
  • get total supply
  • get balance

Fungible token with dynamic supply

Properties:

  • name
  • symbol
  • info

Operations:

  • transfer
  • increate supply
  • decrease supply
  • update owner

Information:

  • get properties
  • get total supply
  • get balance
  • get owner

Non-fungible token with fixed supply

Properties:

  • name
  • symbol
  • info

Operations:

  • transfer unique

Information:

  • get properties
  • get total supply
  • get balance
  • get holder based on token id

Non-fungible token with dynamic supply

Properties:

  • name
  • symbol
  • info

Operations:

  • transfer unique
  • increate supply
  • decrease supply
  • update owner

Information:

  • get properties
  • get total supply
  • get balance
  • get holder based on token id
  • get owner
@WilliamXie9
Copy link

@dexX7 How to create a transaction by this way? can it specify recipients address?

@dexX7
Copy link
Author

dexX7 commented Jun 18, 2019

Hi @WilliamXie9,

currently it's not possible to use this. It's just an idea and draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment