I'm getting this error while sending the 'logicSignature transaction' signed by backend(python) and sent to frontend(react.js) to send the transaction to the network

when I send the logicsign transaction signed by backend-python to frontend, we are getting:

{“message”:“msgpack decode error [pos 294]: only encoded map or array can be decoded into a struct”}

CODE:

			const signed = [];
			signed.push(signedTxns[0].blob);
			signed.push(decoded_txn1);
			signed.push(signedTxns[1].blob);
			signed.push(decoded_txn2);

			console.log("the signe array is :", signed);

			let tx = await client.sendRawTransaction(signed).do();
			console.log("Transaction : " + tx.txId);
			let confirmedTxn = await algosdk.waitForConfirmation(
				client,
				tx.txId,
				4
			);

Welcome to Algorand!

Most likely the issue comes from the signed array should not contain the decoded_txn* transactions, just the signed blobs.

actualy other two transaction are signed at the backend using python and sent to the frontend to submit the transaction. the issue here is the frontend is not able to fetch the blob from this signed object like with the other two sign transaction object.

I would recommend that the backend base64-encode the blob and send them to the frontend.
The frontend base64-decode them.

Using base64 encoding ensures the exact blob is transmitted, even if you have to transmit it through a “text-only” channel such as in a JSON object.

In python, we dont receive any BLOB object after signing the transaction, we only get the transaction object. Only at JS we receive the BLOB object after signing the transaction.

Indeed, in that case, encode the result of transaction.sign in Python as explained there:

Concretely, something like (not tested - please comment if there are typos):

spay_txn = pay_txn.sign(private_key)
return encoding.msgpack_encode(spay_txn))

(remark that Python msgpack_encode already output base64, but in the JS part, you need to base64 decode what you get before adding it to the signed array)

1 Like