How to inscribe drc-20's on DOGE, following the ordinal theory handbook, using bitcoinjs-lib?

99 Views Asked by At

I am trying to write code to inscribe drc-20's using bitcoinjs-lib. Fundamentally, the inscription is just a JSON that adheres to the following format:

{ "p": "drc-20", "op": "deploy", "tick": "woof", "max": "21000000", "lim": "1000" }

Following the ordinal theory handbook, an inscription can be including in a UTXO as follows:

OP_FALSE
OP_IF
  OP_PUSH "ord"
  OP_PUSH 1
  OP_PUSH "text/plain;charset=utf-8"
  OP_PUSH 0
  OP_PUSH "Hello, world!"
OP_ENDIF

Of course here, we'd replace 'Hello, world!" with our inscription (the drc-20).

I am trying to attach an inscription to an utxo by using the following code that inherits from the bitcoinjs-lib library:

/**
 * Creates a PSBT with the given inputs and outputs, and adds an OP_RETURN output with the given text based inscription.
 * @param psbt The PSBT add inscription to.
 * @param inscription The inscription to add to the transaction.
 * @returns The PSBT in bitcoin.Psbt format, with an inscription added.
 */
function createPsbtWithInscriptionRaw(psbt: bitcoin.Psbt, receive_address: string, inscription: string): bitcoin.Psbt {
    // Ensure the inscription is within the allowed byte size
    const data = Buffer.from(inscription, 'utf8');
    if (data.length > 80) {
        throw new Error('Inscription is too long. Must be under 80 bytes.');
    }

    // make the script output
    var script = bitcoin.script.compile([
        bitcoin.opcodes.OP_FALSE,
        bitcoin.opcodes.OP_IF,
        bitcoin.opcodes.OP_PUSH,
        Buffer.from('ordQ', 'utf8'), // doge labs uses this to identify the inscription
        bitcoin.opcodes.OP_PUSH,
        Buffer.from('1', 'utf8'),
        bitcoin.opcodes.OP_PUSH,
        Buffer.from('text/plain;charset=utf-8', 'utf8'),
        bitcoin.opcodes.OP_PUSH,
        Buffer.from('0', 'utf8'),
        bitcoin.opcodes.OP_PUSH,
        Buffer.from(inscription, 'utf8'),  // our actual text inscription
        bitcoin.opcodes.OP_ENDIF,
    ]);


    psbt.addOutput({
        address: receive_address,
        script: script,
        value: 100_000, // minimum value on output, 0.001 DOGE
    });

    // Return the base64 encoded PSBT
    return psbt;
}

Simply, adding the inscription using this psbt does not work. The inscription is not picked up by the indexer, thus when using the extension for the wallet, we can not see our inscription, nor does it appear in any of the tx_hex's from the transaction outputs after pushing the signed PSBT

What is wrong with my code?

Further references

  1. Very doge labs indexer
  2. Wonky Ord (Doge Labs fork of ord)
  3. Doge Labs Waller

Tried to follow the guide to inscribe ordinals on doge, inscriptions are not created properly by bitcoinjs-lib and are not viewable via the indexer as a result.

0

There are 0 best solutions below