0

I am trying to create an app that lets users exchange system-issued (issued by me and delivered to my users) tokens on stellar. the problem is that I can't find anyway of doing so with the included javascript SDK.

how can I do create the exchange operation?

  • Is the question about issuing tokens or exchange one token for the other? – Francesco Nov 21 at 20:24
  • @Francesco exchanging one token for an other – Kaki Master Of Time Nov 24 at 16:16
  • Can you use the distributed exchange? – Francesco Nov 24 at 19:24
  • @Francesco I want to know how to do that via the sdk – Kaki Master Of Time Nov 24 at 20:21
1

The simplest way to exchange tokens between users is to use the Stellar Distributed Exchange (DEX).

There are two types of operations that let you create offers on the DEX:

I included a snippet showing how you can create such transactions and submit them to the network.

    const txA = new Stellar.TransactionBuilder(accountA, { fee })
      .addOperation(Stellar.Operation.manageSellOffer({
          selling: assetX,
          buying: assetY,
          amount: '1000000',
          price: '1',
          offerId: '0',
      }))
      .setTimeout(30)
      .setNetworkPassphrase(Stellar.Networks.TESTNET)
      .build();
    txA.sign(A);
    await server.submitTransaction(txA);

    const txB = new Stellar.TransactionBuilder(accountB, { fee })
      .addOperation(Stellar.Operation.manageBuyOffer({
          buying: assetY,
          selling: assetX,
          buyAmount: '1000',
          price: '1',
          offerId: '0',
      }))
      .setTimeout(30)
       setNetworkPassphrase(Stellar.Networks.TESTNET)
      .build();
    txB.sign(B);
    await server.submitTransaction(txB);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.