2

I am trying to issue an asset in stellar using the following code

var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

// Keys for accounts to issue and receive the new asset
var issuingKeys = StellarSdk.Keypair.fromSecret('SB3VKUYOWTOZKN3IUTLKE4IMEDEMPVPY6ZRQTPP74XZKRxxxNCIKExxx');
//console.log(issuingKeys);

var receivingKeys = StellarSdk.Keypair.fromSecret('SB3Q65ARACYPDK5FxxxLG2KPPFZT7R3SVPPBQAPW6FC75XNxxx3LNLGB');

// Create an object to represent the new asset
var astroDollar = new StellarSdk.Asset('AstroDollar', issuingKeys.publicKey());

// First, the receiving account must trust the asset
server.loadAccount(receivingKeys.publicKey())
  .then(function(receiver) {
    const fee =  server.fetchBaseFee();

    var transaction = new StellarSdk.TransactionBuilder(receiver,   {fee} )
      // The `changeTrust` operation creates (or alters) a trustline
      // The `limit` parameter below is optional
      .addOperation(StellarSdk.Operation.changeTrust({
        asset: astroDollar,
        limit: '1000'
      }))
      .setTimeout(30)
      .build();
    transaction.sign(receivingKeys);
    return server.submitTransaction(transaction);
  });

But I'm getting the following error (node:9922) UnhandledPromiseRejectionWarning: Error: XDR Write Error: not an integer, Can anyone tell me how to resolve this issue?

1 Answer 1

4

fetchBaseFee is a promise, you have to await it.

const fee =  await server.fetchBaseFee();
2
  • Thanks sui for your response, If I removing the quotes I am getting the following error "Error: invalid encoded string"
    – M Gopi
    Commented Mar 15, 2019 at 12:14
  • Just tested it, ok should be string... anyways I've updated the answer.
    – sui
    Commented Mar 15, 2019 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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