2

I am new to stellar so please bear with my question if it sounds too basic. So, using the stellar laboratory, I created two accounts lets name 1 and 2. I funded the 1st account with test-net coins using friend-bot and left the 2nd account empty. Now as I understand that an account to be active on stellar network, it should have a minimum balance of about 1XLM. So using the transaction builder, I tried to perform a Payment Operation by trying to transfer 2XLM to the 2nd account. However I recieved the following response :

{
  "type": "https://stellar.org/horizon-errors/transaction_failed",
  "title": "Transaction Failed",
  "status": 400,
  "detail": "The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details.  Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html",
  "extras": {
    "envelope_xdr": "AAAAAKNyr+6/r2REKzMV3sOL4jztg1HSdqlQhmthUU41BjPdAAAAZAAEmkQAAAADAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAmWhqbEZTUrZWFtvR1HU7VUW0pp3BwN4E9h4iQwvMr9kAAAAAAAAAAAExLQAAAAAAAAAAATUGM90AAABAHvtdpnjhq3usHFphQ/4naDHbKVhu+QqD8UFSavo/qlGo7Yiz/dLI3lQ0fmfa37uvwXWsYAn8mObDkrTjofc3Aw==",
    "result_codes": {
      "transaction": "tx_failed",
      "operations": [
        "op_no_destination"
      ]
    },
    "result_xdr": "AAAAAAAAAGT/////AAAAAQAAAAAAAAAB////+wAAAAA="
  }
}

So can someone tell me which operation I need to use to send XLM to an un-initialised address so I can activate it, not by using friendbot.

2 Answers 2

1

The very first payment to an uninitialized account has to be performed with the createAccount operation.

0

The first time you're trying to send tokens to an uninitialised account, you have to use the createAccount method on Operations ie

const transaction = new StellarSdk.TransactionBuilder(senderAccount, {
    fee: feeInStroops,
    networkPassphrase, // Use the testnet passphrase
  })
    .addOperation(
      StellarSdk.Operation.createAccount({
        destination: 'GCVTRT3OP3B7BJJDHHXG2UFMI76RBZDSYUDD37WUKVF2IV6TK6RRJXXN', // Replace with the recipient's public key
        asset: StellarSdk.Asset.native(), // Use Stellar Lumens (XLM)
        startingBalance: '1', // The amount to send
      })
    )
    .setTimeout(300)
    .build();
1
  • Welcome to Stellar! We've noticed you posted the same answer to four questions; please make sure your answer addresses the question in the best possible manner. See the Help Center article How to Answer.
    – Glorfindel
    Sep 4, 2023 at 17:19

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.