3

I tried creating an asset by following this link: Issuing Assets.

I am able to successfully issue asset and transfer to another account. But when I check the balance of other accounts, I get:

Type: credit_alphanum12 , Balance: 10.0000000
Type: credit_alphanum12 , Balance: 10.0000000
Type: native , Balance: 9981.9998400

I don't know why the assets name didn't appear. I can't distinguish between assest if I don't see their names.

This is the code snippet I used:

To issuse asset

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

Complete code:

var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var server = new StellarSdk.Server('http://127.0.0.1:8000', {allowHttp: true});

// Keys for accounts to issue and receive the new asset
var issuingKeys = StellarSdk.Keypair
  .fromSecret('______secret key_issuer__________');
var receivingKeys = StellarSdk.Keypair
  .fromSecret('______secret key_receiver__________');

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

// First, the receiving account must trust the asset
server.loadAccount(receivingKeys.publicKey())
  .then(function(receiver) {
    var transaction = new StellarSdk.TransactionBuilder(receiver)
      // The `changeTrust` operation creates (or alters) a trustline
      // The `limit` parameter below is optional
      .addOperation(StellarSdk.Operation.changeTrust({
        asset: astroDollar,
        limit: '1000'
      }))
      .build();
    transaction.sign(receivingKeys);
    return server.submitTransaction(transaction);
  })

  // Second, the issuing account actually sends a payment using the asset
  .then(function() {
    return server.loadAccount(issuingKeys.publicKey())
  })
  .then(function(issuer) {
    var transaction = new StellarSdk.TransactionBuilder(issuer)
      .addOperation(StellarSdk.Operation.payment({
        destination: receivingKeys.publicKey(),
        asset: astroDollar,
        amount: '10'
      }))
      .build();
    transaction.sign(issuingKeys);
    console.log("success")
    return server.submitTransaction(transaction);
  })
  .catch(function(error) {
    console.error('Error!', error);
  });

What exactly am I missing?

1 Answer 1

4

I understand you are parsing /accounts/{id} endpoint. A single balance object is of the following form:

{
  "balance": "0.0000000",
  "limit": "922337203685.4775807",
  "asset_type": "credit_alphanum4",
  "asset_code": "BTC",
  "asset_issuer": "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH"
}

You are probably printing asset_type field only. You should print asset_code and asset_issuer fields because they uniquely represent an asset.

1

Your Answer

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

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