How to opt-in asset to stateless escrow contract using algosigner, then from escrow to other wallet address?

Hi @Maugli @barnji @fabrice @liz
I have trouble creating escrow contract, can I have non-production escrow teal contract. And I have errors while optin asset-id to escrow by doing this:

AlgoSigner.connect()
.then(async(d) => {
  AlgoSigner.accounts({
    ledger: 'TestNet'
  })
  .then(async(d) => {

    console.log("TestNet",d)
//new code added 191021

AlgoSigner.algod({
  ledger: 'TestNet',
  path: '/v2/transactions/params'
})
// sign new opt-in transaction
.then((txParams) => AlgoSigner.sign({
  assetIndex: assetId,
  from: lsig.address(),
  amount: 0,
  to: optInAccount,
  type: 'axfer', // ASA Transfer (axfer)
  fee: txParams['min-fee'],
  firstRound: txParams['last-round'],
  lastRound: txParams['last-round'] + 1000,
  genesisID: txParams['genesis-id'],
  genesisHash: txParams['genesis-hash'],
  flatFee: true
}))
// send signed transaction
.then((signedTx) => AlgoSigner.send({
  ledger: 'TestNet',
  tx: signedTx.blob
}))
// wait for confirmation from the blockchain
.then((tx) => waitForAlgosignerConfirmation(tx)) // see algosignerutils.js
.then(async(d) => {
  // was successful

  
  //transfer

assetId = Number(parseInt(idget))
let from = localStorage.getItem("wallet"); 
let to = lsig.address(); 
let amount = 1; 
let note = undefined; 

AlgoSigner.algod({ 
        ledger: 'TestNet', 
        path: '/v2/transactions/params'
    })
    .then((txParams) => AlgoSigner.sign({
      assetIndex: assetId,
        from: from,
        to: to,
        amount: +amount,
        note: note,
        type: 'axfer',
        fee: txParams['min-fee'],
        firstRound: txParams['last-round'],
        lastRound: txParams['last-round'] + 1000,
        genesisID: txParams['genesis-id'],
        genesisHash: txParams['genesis-hash'],
        flatFee: true
    })) 
    .then((signedTx) => AlgoSigner.send({ 
        ledger: 'TestNet', 
        tx: signedTx.blob 
    }))
    // wait for confirmation from the blockchain
    .then((tx) => waitForAlgosignerConfirmation(tx)) // see algosignerutils.js
    .then((tx) => {
        // our transaction was successful, we can now view it on the blockchain 
        console.log("transfer success",tx)
      })
      .catch((e) => {
        console.error(e);
      })
      
    
  //end
})
.catch((e) => {
  console.error(e);
})
.catch((e) => {
  console.error(e);
});

  
  
//new code ended 191021
  })
  .catch((e) => {
    console.error(e);
  });
})
.catch((e) => {
  console.error(e);
});

The from and to fields should both be set to the address of the account trying to opt-in

After using like, from and to as same account,
It is showing that:

message: “No matching account found on AlgoSigner for address: "RWYPYF5XX4OP2L6BCMZAA4ETP3S3HSF32QSWSGMXAUO5NBJPKPHR6YCCAE" on network TestNet.”

It is showing error that the algosigner does not have the escrow account in it.
How to fix this?

AlgoSigner.connect()
.then(async(d) => {
  AlgoSigner.accounts({
    ledger: 'TestNet'
  })
  .then(async(d) => {

    console.log("TestNet",d)
//new code added 191021

AlgoSigner.algod({
  ledger: 'TestNet',
  path: '/v2/transactions/params'
})
// sign new opt-in transaction
.then((txParams) => AlgoSigner.sign({
  assetIndex: assetId,
  from: lsig.address(),
  amount: 0,
  to: lsig.address(),
  type: 'axfer', // ASA Transfer (axfer)
  fee: txParams['min-fee'],
  firstRound: txParams['last-round'],
  lastRound: txParams['last-round'] + 1000,
  genesisID: txParams['genesis-id'],
  genesisHash: txParams['genesis-hash'],
  flatFee: true
}))
// send signed transaction
.then((signedTx) => AlgoSigner.send({
  ledger: 'TestNet',
  tx: signedTx.blob
}))
// wait for confirmation from the blockchain
.then((tx) => waitForAlgosignerConfirmation(tx)) // see algosignerutils.js
.then(async(d) => {
  // was successful

  
  //transfer

assetId = Number(parseInt(idget))
let from = localStorage.getItem("wallet"); 
let to = lsig.address(); 
let amount = 1; 
let note = undefined; 

AlgoSigner.algod({ 
        ledger: 'TestNet', 
        path: '/v2/transactions/params'
    })
    .then((txParams) => AlgoSigner.sign({
      assetIndex: assetId,
        from: from,
        to: to,
        amount: +amount,
        note: note,
        type: 'axfer',
        fee: txParams['min-fee'],
        firstRound: txParams['last-round'],
        lastRound: txParams['last-round'] + 1000,
        genesisID: txParams['genesis-id'],
        genesisHash: txParams['genesis-hash'],
        flatFee: true
    })) 
    .then((signedTx) => AlgoSigner.send({ 
        ledger: 'TestNet', 
        tx: signedTx.blob 
    }))
    // wait for confirmation from the blockchain
    .then((tx) => waitForAlgosignerConfirmation(tx)) // see algosignerutils.js
    .then((tx) => {
        // our transaction was successful, we can now view it on the blockchain 
        console.log("transfer success",tx)
      })
      .catch((e) => {
        console.error(e);
      })
      
    
  //end
})
.catch((e) => {
  console.error(e);
})
.catch((e) => {
  console.error(e);
});

  
  
//new code ended 191021
  })
  .catch((e) => {
    console.error(e);
  });
})
.catch((e) => {
  console.error(e);
});

Pinging the AlgoSigner devs

Hello! Have you tried importing the escrow account into AlgoSigner?

No, our usecase is to create a nft market place where unknown users will use, How come they have our escrow in their Algosigner?

You need only need to import it yourself in order to make the opt-in. Opt-in is only needed to be done once per account, so you can do it by hand and remove it from the user-accesible code :slight_smile:

Otherwise, it’s not supported to make transactions for other accounts without having access to them first. You can bring it up to the Algorand Foundation.