Signing transactions in tx group result into error: 'The transaction group is incomplete or presented in a different order than when it was created.'

Hello fabrice,

  1. I’m generating the lsigAccount like this:

From the client side I’m requesting the teal source code of the nft escrow contract (relies on token id and app id) from the server and then the server is returning the teal source as a string and looks something like this:

returned TEAL code:

#pragma version 4
global GroupSize
int 3
==
assert
gtxn 0 ApplicationID
int 87793081
==
assert
gtxn 1 TypeEnum
int pay
==
assert
gtxn 2 AssetAmount
int 1
==
assert
gtxn 2 XferAsset
int 87793064
==
assert
gtxn 2 Fee
int 1000
<=
assert
gtxn 2 AssetCloseTo
global ZeroAddress
==
assert
gtxn 2 RekeyTo
global ZeroAddress
==
assert
int 1
return

Then on the client side a class nftEscrowContract calculates the stateless smart contract related stuff such as lsigAccount and escrowAddress like this:

    // here this.escrowTealSource is the teal code retrieved from the server mentioned before
    async init()
    {
    try
        {
            this.escrowBytes = await this.calculateEscrowBytes(this.escrowTealSource);
            this.escrowAddress = await this.calculateEscrowAddress();
            return true;
        }
        catch(err)
        {
            console.log(err);
            return false;
        }
    }

    async calculateEscrowBytes(tealSource)
    {
        console.log('calculating escrow bytes...');

        let encoder = new TextEncoder();
        let programBytes = encoder.encode(tealSource);
        let compileResponse = await this.client.compile(programBytes).do();
        let escrowBytes = new Uint8Array(Buffer.from(compileResponse.result, "base64"));

        console.log('escrow bytes calculated: ' + escrowBytes);

        return escrowBytes;
    }

    async calculateEscrowAddress()
    {
        console.log('calculating escrow address...');
        this.lsigAccount = new algosdk.LogicSigAccount(this.escrowBytes);
        let escrowAddress = this.lsigAccount.address();
        console.log('escrow address calculated ' + escrowAddress);
        return escrowAddress;
    }

So I’m calculating lsigAccount like this:

this.lsigAccount = new algosdk.LogicSigAccount(this.escrowBytes);
  1. Printing signedAxferTx like this
console.log(Buffer.from(signedAxferTx.blob).toString("base64"));

returns:
gqRsc2lngaFsxAr///////////8Bo3R4boykYWFtdAGkYXJjdsQgcIQIU3m1yEcmO5GugQcx+aS2hP0gNds8lZ50T0YDfdWkYXNuZMQgGZqLP/+X2hXE75NlJGaJUfSEs8G1FjOspUGdILkaHWmjZmVlzQPoomZ2zgFS9zajZ2VurHRlc3RuZXQtdjEuMKJnaMQgSGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiKjZ3JwxCDO6kV+H6vS+M9ea728TiVKW3HBg1c4KEXmpnYkFauIyqJsds4BUvseo3NuZMQgee0gtqGVdHwlYmkhocmIbTYzn2Q+a/5uvH/aKsHKgLakdHlwZaVheGZlcqR4YWlkzgU7nag=

  1. I’m using TESTNET using purestake’s client.

Something strange I just noticed, the escrow address generated on the server is different from the one generated on the client but they seemingly using the same source code :thinking: Any ideas what might be the issue?

Many thanks