Tezos Transaction Signing

To sign and broadcast the transaction to the Tezos network, follow these steps:

  1. Prepare unsigned transaction as a hex-encoded string.
    You obtain this from the unsignedTransactionData field in the Unified API staking/unstaking response.

  2. Sign the transaction using the following code:

import { InMemorySigner } from '@taquito/signer';

const MNEMONIC = "<YOUR_MNEMONIC>";
const UNSIGNED_TX = "<UNSIGNED_TX_HEX>";

async function main() {
    // Create a signer instance from mnemonic
    const signer = await InMemorySigner.fromMnemonic({ mnemonic: MNEMONIC });

    // Sign the unsigned transaction (hex string)
    const signed = await signer.sign(UNSIGNED_TX, new Uint8Array([3]));

    // The result contains: bytes, sig, prefixSig, sbytes
    console.log("✅ Signed Tezos Tx (JSON):");
    console.log(JSON.stringify(signed, null, 2));
}

main().catch(console.error);

Upon successful execution, the script prints the signed transaction as a JSON object, ready to be broadcasted:

✅ Signed Tezos Tx (JSON):
{
  "bytes": "...",
  "sig": "...",
  "prefixSig": "...",
  "sbytes": "..."
}
  1. Broadcast the transaction to the Tezos network by sending a POST request to /api/v1/unified/transaction/broadcast.

What's Next?