<p>A was able to do that. I posted a small snippet:</p>

<p><a href="https://gist.github.com/caffeinum/f64a51ce55d5ac9075bb2f5f2f439c0d" rel="noreferrer">https://gist.github.com/caffeinum/f64a51ce55d5ac9075bb2f5f2f439c0d</a></p>

<p>If you're familiar with <code>bitcoinjs-lib</code>, the omni-specific piece of code for tx creation:</p>

<pre><code>  const simple_send = [
    "6f6d6e69", // omni
    "0000",     // version
    "00000000001f", // 31 for Tether
    "000000003B9ACA00" // amount = 10 * 100 000 000 in HEX
  ].join('')

  const data = Buffer.from(simple_send, "hex")

  const omniOutput = bitcoin.script.compile([
    bitcoin.opcodes.OP_RETURN,
    // payload for OMNI PROTOCOL:
    data
  ])

  tx.addOutput(recipient_address, fundValue) // should be first!
  tx.addOutput(omniOutput, 0)

  tx.addOutput(alice_address, skipValue)
</code></pre>

<p>If you're insterested in working towards publishing small library, feel free to tap me at <a href="https://bykhun.com" rel="noreferrer">https://bykhun.com</a></p>

CC BY-SA 4.0
2018-08-15T19:32:53.560Z
2018-08-15T19:32:53.560Z
caffeinum
<p>As far as I understand from reading a <a href="https://github.com/OmniLayer/spec" rel="nofollow noreferrer">specification</a> and this <a href="https://medium.com/omnilayer/optimizing-the-payloads-of-omni-layer-transactions-ccb0a867da5d" rel="nofollow noreferrer">blogpost</a>, creating Omnilayer transactions is a rather tough thing to do yourself, because format is quite intricate. Are there any examples on how to create and decode omni transactions in javascript/python? Or maybe there is even some lightweight library for this?</p>

<p>What I'm trying to do is to send my custom omni transactions to blockchain.info testnet and later discover them by another app. That's why I need to be able to both create and decode them. However I couldn't find any helpful resources on how to accomplish this.</p>

<transactions><omni>
How to create an omnilayer transaction by myself?
Wunsch Punsch
# How to create an omnilayer transaction by myself?

(Asked by: username_0 on 2018-04-29)

As far as I understand from reading a [specification](https://github.com/OmniLayer/spec) and this [blogpost](https://medium.com/omnilayer/optimizing-the-payloads-of-omni-layer-transactions-ccb0a867da5d), creating Omnilayer transactions is a rather tough thing to do yourself, because format is quite intricate. Are there any examples on how to create and decode omni transactions in javascript/python? Or maybe there is even some lightweight library for this?

What I'm trying to do is to send my custom omni transactions to blockchain.info testnet and later discover them by another app. That's why I need to be able to both create and decode them. However I couldn't find any helpful resources on how to accomplish this.

**Tags:** transactions, omni


---

## 1 answers

### Answer by username_1 on 2018-08-15. Score: 6

A was able to do that. I posted a small snippet:
https://gist.github.com/username_1/f64a51ce55d5ac9075bb2f5f2f439c0d
If you're familiar with bitcoinjs-lib, the omni-specific piece of code for tx creation:
  const simple_send = [
    "6f6d6e69", // omni
    "0000",     // version
    "00000000001f", // 31 for Tether
    "000000003B9ACA00" // amount = 10 * 100 000 000 in HEX
  ].join('')

  const data = Buffer.from(simple_send, "hex")

  const omniOutput = bitcoin.script.compile([
    bitcoin.opcodes.OP_RETURN,
    // payload for OMNI PROTOCOL:
    data
  ])

  tx.addOutput(recipient_address, fundValue) // should be first!
  tx.addOutput(omniOutput, 0)

  tx.addOutput(alice_address, skipValue)

If you're insterested in working towards publishing small library, feel free to tap me at https://bykhun.com


---

