As per stellar documentation they provide manageOffer function to create, update and delete an offer, i am enable to use this function can anybody please help me to give me some instructions or any code reference which help me to create new offers.


The manage offer operation is used to create a new offer. Just set the offer id to 0, or omit it.

offerId number | string optional

If 0, will create a new offer (default). Otherwise, edits an exisiting offer.

  • Can you have a source code reference because i am trying so many source code but nothing helps me to create a new offer as i have tried the offerId param to 0 also may be my code didn't work. Feb 21 '18 at 6:35
  • It should be very similar to stellar.org/developers/js-stellar-sdk/reference/examples.html except with manage offer instead of payment operation. Please update your question with what you have tried and what the error is.
    – Synesso
    Feb 21 '18 at 7:23
  • I am getting below error: TypeError: opts.selling.toXDRObject is not a function at Function.manageOffer Feb 22 '18 at 6:08
//initialize stellar sdk
var StellarSdk = require('stellar-sdk')
        var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
var op ={
                selling: selling_asset,
                buying: buying_asset,
                amount: amount,
                price: price,
                offerId:0 // for creating new offer id must be 0
        var sourcePublicKey = sourceKeypair.publicKey();
          .then(function(account) {
            var transaction = new StellarSdk.TransactionBuilder(account)
              // Add a manageOffer operation
//sign transaction
              .then(function(transactionResult) {
                console.log(JSON.stringify(transactionResult, null, 2));
                console.log('\nSuccess! View the transaction at: ');
              .catch(function(err) {
                console.log('An error has occured:');
          .catch(function(e) {
  • Would you mind improving your answer by adding explanations to your code. Feb 26 '18 at 16:23
  • How did you resolve : : opts.selling.toXDRObject is not a function at Function.manageOffer ? I am also getting same error. Apr 3 '18 at 10:58
  • @PrashantPrabhakarSingh did you try to use above code source ? Apr 9 '18 at 1:05
  • Yes, I did. The problem was the way I was declaring asset names. Resolved it. :) Apr 9 '18 at 5:25

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.