#Does anyone have a js client example for the Atomic Swap demo?

1 messages · Page 1 of 1 (latest)

pulsar surge
#

Hey everybody!

I'm working on a pipeline for soroban authentication and I'm having difficulties to generate and sign the authorization entries to authenticate a require_auth_for_args. I'm using the atomic swap example from the docs but so far I haven't been able to successfully execute a multiswap ( example ). The transactions get executed but the swap doesn't happen and I believe it is because I'm not properly generating the authorization entry.

Does anyone have an example of a client-side generating and signing the entries for this example or a similar one?

stiff heart
#

since when sir

#

@pulsar surge

pulsar surge
# stiff heart <@420009743516565504>

Hey @stiff heart !
how is it going? Hope you're doing well!

I'm working on it for a few days to integrate on [Stellar Plus] (https://cheesecake-labs.gitbook.io/stellar-plus/?utm_source=github&utm_medium=codigo-fonte). So far I managed to make a pipeline that already identifies necessary entries to authorize from a simulation and handles that automatically (PR is being reviewed before releasing this version).

Now I wanted to dive deeper into these more complex scenarios and began looking into the Atomic Swap example but I'm struggling 😦

pulsar surge
#

Update: I think I've found my mistake! I wasn't looking at it from the perspective of authorizing the subinvocations specifically for the contract that validates the args authorization. I was treating the whole thing as one invocation and trying to authorize the args for the batch contract only.

Here I've authorized specifically the swap contract and executed it successfully.
https://stellar.expert/explorer/testnet/tx/5df8465b0f5ea7d920959c20d40a38c5a86c31477ca8e0ee0c6458e6914d036d

I'll try and expand from here to the batch contract 🙏

rugged cobalt
pulsar surge
#

Thank you @rugged cobalt ! I'll look into it as a reference!!

pulsar surge
#

**UPDATE: Got it!! ** 🎊 🚀 🎊 🚀 🎊 🚀

Look at this beauty! (screenshot)

My main objective was to run the multi swap demo in the following way:

A. All accounts authorize their own swaps without knowing any of the other users' swap intentions
B. Multi swap gets all user swaps and their auth entries and sorts out the matches and then, triggers the atomic swap for these

I was initially having trouble to generate each account authorization because I had the wrong understanding I would have to generate those manually and not be able to simulate the atomic swap without knowing the other pair beforehand. It all clicked when going thorough the simulations and noticing that the authorization entry generated from it was already covering only the necessary authorization for that account involvement in the transaction, so it was all about the workflow.

In this example I did the following:

  1. Setup 7 accounts and prepare their own random swap parameters.
  2. For each one of those I simulate their individual atomic swap with a dummy account that won't be involved in the actual swaps. It is just to run a valid swap simulation.
  3. Extract the auth entry from this simulation and sign
  4. Bundle all random accounts swaps and authorization and trigger the multi swap
  5. Let the magic happen!

It is really nice to see how everything is handled graciously in the batch execution!

#

Thank you so much @rugged cobalt ! The example helped me getting to the a-ha moment!