Adding a Memo to a Bitcoin Transaction

Hello :wave:

I was looking for an example of adding a memo to a Bitcoin transaction with Rosetta. Would it be simply be adding an additional Operation with the following values in the Metadata field?

import * as BitcoinJS from 'bitcoinjs-lib'

const senderAddress = 'xyz';
const memo = 'Hello World';

const ops = [... other operations to send transaction]

const memoOperation = {
      operation_identifier: {
        index: ops.length - 1,
      type: 'OUTPUT',
      account: {
        address: senderAddress,
      amount: {
        value: '0',
        currency: {
          symbol: 'tBTC',
          decimals: 8,
      metadata: {
        scriptPubKey: {
          asm: `OP_RETURN ${BitcoinJS.script.toASM(Buffer.from(memo))}`,
          hex: Buffer.from(memo).toString('hex'),
          type: 'nulldata',

When I test out the above code, I get the error “Unable to parse intent” when passing to the payloads endpoint.


That’s a great question, @stuart! Unfortunately, the existing rosetta-bitcoin implementation only supports orchestrating simple sends. I’m all for you adding an extension to support more complex sends in rosetta-bitcoin (would just involve adding some logic to treat an output specially if it has some metadata).

All related logic can be found in this file:

Hey @patrick.ogrady, thanks for the response. Sounds good, we can take a stab at it. To discuss how to implement, created an issue for this in github

1 Like