I am creating a multi-sign transaction. When I am submitting the transaction to Stellar, response.isSuccess() returns false. Could anyone tell me where I am going wrong? link https://www.stellar.org/developers/js-stellar-base/reference/base-examples.html#multi-signature-account

public static void main(String[] args) {
    Server server = new Server("https://horizon-testnet.stellar.org");

    KeyPair source = KeyPair.fromSecretSeed("SC4EJSKMHQLHRUWFYC7O62OP2QPQ2HD7IOXCHKR2STVPAQ6E5MBXXRAI");

    KeyPair source1 = KeyPair.fromSecretSeed("SCR5ARAIDZ6EW4NRVFUP35CY444S3D4H52GIVKW46D736UFFVQFLLVY4");
    KeyPair secondary1 = KeyPair.fromAccountId("GAU3GFO7L3TECSZ2ARAHACTQ44QKHKU355PHWBLRIWHXIDXBRHMNOYVQ");

    KeyPair destination = KeyPair.fromAccountId("GCFOSKTU4N4OPOXFGA473V2DG36QBCHNPHXOLU4W2BZL5TZH4GCZS5BN");

    try {
    } catch (IOException e1) {

    AccountResponse sourceAccount = null;
    try {
        sourceAccount = server.accounts().account(source);
        sourceAccount = server.accounts().account(source1);
    } catch (IOException e1) {

    Transaction transaction = new Transaction.Builder(sourceAccount)
            .addOperation(new SetOptionsOperation.Builder().setSigner(secondary1.getXdrSignerKey(), 1)
    transaction = new Transaction.Builder(sourceAccount)
            .addOperation(new PaymentOperation.Builder(destination, new AssetTypeNative(), "11").build())
            .addMemo(Memo.text("Test Transaction"))

    try {
        SubmitTransactionResponse response = server.submitTransaction(transaction);

    } catch (Exception e) {

You are getting an error because of a bad sequence number. I know this because I decoded response.getResultXdr(). Here are some things you should know:

  1. When you call sourceAccount = server.accounts().account(source), sourceAccount will have the correct sequence number.
  2. When you call build(), the TransactionBuilder will increment the account's sequence number by 1, so that the account is ready to participate in a new transaction
  3. Because you never submit the first transaction, that sequence number is never used.
  4. When you reassign transaction = new Transaction.Builder(sourceAccount), sourceAccount has the incremented sequence number.
  5. When you submit the second transaction, the network rejects it because it never received the preceding sequence number.

Although I'm not sure what you're trying to do, you need to make sure that you call build once before calling submitTransaction.

| improve this answer | |

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.