3

As far as I understand from reading a specification and this blogpost, 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.

5

A was able to do that. I posted a small snippet:

https://gist.github.com/caffeinum/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

| improve this answer | |
  • 1
    thank you. you rock. i love you. – nick carraway Mar 14 '19 at 17:46

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.