Offline signing! How to get a raw binary string of the signed transaction for sending to an API?


I am creating a transaction and signing it offline. I want to send this data to algo blockchain by pasting it into the Developer API utility.

Can anyone advise me how to obtain the binary string from the signed transaction blob?

const algo = require('algosdk');
var testTxn = { ... };

var signedTxn = algo.signTransaction(testTxn, secretKey);

^^^ This works, I obtain an object.

// convert Uint8Array to string
var raw = String.fromCharCode.apply(null, signedTxn.blob);

^^^ This gives me a string, but when I submit it to the API, I get this error:
"msgpack decode error [pos 1]: only encoded map or array can be decoded into a struct"

How should I obtain the raw data of signed transaction blob that an api such as algoexplorer or PureStake will accept?

I’ve tried using client.sendRawTransaction(signedTxn.blob).do() with PureStake and this works, but it’s not exactly offline since there needs to be a connected client.

My goal with this (tedious) workflow is to create an airgap for the signing computer.

Thanks for your help!

You may want to look at

Thanks, but I’ve already looked, and it doesn’t give the solution.
It only shows how to use sendRawTransaction, not obtain the raw binary string.

See the function saveSignedTransaction in the “Complete Example = Saving Signed and Unsigned Transactions to a File” at the bottom of the page

This example saves the full transaction object to a file (signature and the blob), then reads it back from a file.

It still uses the sendRawTransaction() function (which only sends the blob) and doesn’t expose the raw binary that’s being sent to the API.

Why not save the signed tx and move to another computer and use goal to sumbit it or curl?
ie curl -s -X POST --data-binary “@./rawsigned.tx” -H "X-Algo-API-Token: APITOK" "http://{API}/v2/transactions

You can use Buffer.from on the blob to get a Buffer object, if you’re using NodeJS (

See what sendRawTransaction does: