Msgpack decode error with multisig transaction with Javascript SDK - Algorand
Msgpack decode error with multisig transaction with Javascript SDK
post by bayuobie on Feb 4, 2021
I am sending a multisig transaction but get an error when I try posting that to the chain with the error
msgpack decode error [pos 1]: only encoded map or array can be decoded into a struct
I am not doing any encoding and I get the transaction ID after signing it but submission to the chain then returns a 400 error code with the message above.
Below is a sample transaction details.
{txID: "45EJOSSI7UQW27RHBN6KY5ULMWC5JYUAF4UZ7SERFKHBIGA2TPXQ", blob: Uint8Array(457)}
post by fabrice on Feb 4, 2021
Can you provide the code that generates the error?
PS: You can write the code between triple backquotes to make it look nicer. Example:
const example = 5;
post by bayuobie on Feb 4, 2021
Here is the code
let txn = {
"to": PayoutRecipient[0],
"fee": getParams.fee,
"amount": amountToPay,
"firstRound": getParams["last-round"],
"lastRound": getParams["last-round"] + 1000,
"genesisID": getParams["genesis-id"],
"genesisHash": getParams["genesis-hash"],
"note": new Uint8Array("payment"),
};
let signedTxn = algosdk.signMultisigTransaction(txn, mparamsAccount, itemPay.sk);
fetch(traxUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-binary',
},
body: signedTxn,
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch((error) => {
console.error('Error:', error);
});
post by JasonW on Feb 4, 2021
What is the value of traxUrl?
post by fabrice on Feb 4, 2021
I think the issue is that signedTxn is an object with two properties: txID and blob.
You need to only send blob:
fetch(traxUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-binary',
},
body: signedTxn.blob,
})