Signing transactions on Algorand network for a (SWAP)

Say I am working on a swap on algorand to swap certain amount of tokens from one ASA to for an equivalent amount in another ASA, What do I need to do to sign the transaction of the other account that has the tokens I want to swap for.
I can’t seem to perform the swap if I do not have the account to sign its transaction for me to perform the swap successfully. 2021-11-13 17_31_37-React App

I want anyone to be able to perform the swap and sign the transaction without having the other account in my wallet. Is there a way to go about this?

You need to manually specify transactions that should not be signed using signers: [].
See:

let signedTxs = await AlgoSigner.signTxn([
  {
    txn: base64Txs[0],
  },
  {
    // This tells AlgoSigner that this transaction is not meant to be signed
    txn: base64Txs[1],
    signers: [],
  },
]);

in algosigner/dApp-integration.md at 91b1463cfcb19de513ff6bd55424987ed6fcc9f0 · PureStake/algosigner · GitHub

Is there a way I can use signers: in this format?
2021-11-15 21_21_54-swap.js - react-algo - Visual Studio Code
I am using AlgoSigner.sign not AlgoSigner.Txn

I don’t seem to have AlgoSigner.Txn in my options:

I don’t know what you use for auto-completion, but I don’t think it’s an issue.
As AlgoSigner is injected by the browser, your IDE may not know what the AlgoSigner object contains.
sign is the legacy signing method. You need to switch to signTxn and follow algosigner/dApp-integration.md at 91b1463cfcb19de513ff6bd55424987ed6fcc9f0 · PureStake/algosigner · GitHub

So does that mean with the use of signers: , any address with tokens (e.g Algo tokens) can be used as the sender address and the transaction will work?
So long as it tells AlgoSigner not to sign the transaction??

AlgoSigner won’t complain.
But then you still need to get those transactions signed in another way, i.e., using a smart signature or a secret key stored somewhere else.

1 Like

Smart Sig will be the way forward for this then.
Thank you

One more thing please, If I am to create a smart sig / logic sig that will interact with an actual pool, do you have links/resources you can pinpoint me to as to what I can use to get my hands on to create a swap dex? Atomic Transactions (1. Tx fees, 2. Application call, 3. ASA/Algo transfer 4. ASA/Algo transfer) grouped in an atomic transaction similar to how Tinyman swap works. This is a video demo to what I currently have working: Link

Tinyman is open source:

The design docs are there: Design Doc - Tinyman Docs

But you may also want to start with simpler “solutions” on developer.algorand.org.

1 Like