I want to generate a signedTransaction from web client side, send the signedTransaction to server side, where I do some additional handling and then broadcast it.
Everything works fine if I submit from client side. Like this
let txn = algosdk.makeAssetCreateTxnWithSuggestedParams(accountAddr, note, totalSupply, decimals, defaultFrozen, managerAddress, reserveAddress, freezeAddress, clawbackAddress, unitName, assetName, assetURL, "", getParams);
let signedTxn = txn.signTxn(thisAccount.sk);
var postTransactionUrl = "https://testnet.algoexplorerapi.io/v2/transactions";
var reqOptions = {
method: "POST",
headers: {
"Content-Type": "application/x-binary",
},
body: signedTxn
};
const txDetails = await (await fetch(postTransactionUrl, reqOptions)).json();
But when I pass the signedTransaction to my server via an https endpoint, the signedTxn somehow gets messed up and I get an error msg “msgpack decode error [pos 1]: only encoded map or array can be decoded into a struct”
// client side
let txn = algosdk.makeAssetCreateTxnWithSuggestedParams(accountAddr, note, totalSupply, decimals, defaultFrozen, managerAddress, reserveAddress, freezeAddress, clawbackAddress, unitName, assetName, assetURL, "", getParams);
let signedTxn = txn.signTxn(thisAccount.sk);
const createAsset = firebase.functions().httpsCallable("createAsset");
createAsset({
"mode": "test",
"signedTxn": signedTxn
});
//server side
exports.createAsset = functions.https.onCall(async (data, context) => {
var postTransactionUrl = "https://testnet.algoexplorerapi.io/v2/transactions";
var reqOptions = {
method: "POST",
headers: {
"Content-Type": "application/x-binary",
},
body: data.signedTxn
};
const txDetails = await (await fetch(postTransactionUrl, reqOptions)).json();
});
Ive tried JSON stringify on client then JSON parse on server side, I’ve tried the algosdk.decodeObj then algosdk.encodeObj. But nothing works. Anyone else have similar problems?