Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Albedo Intent tx Signing is different from Stellar SDK Signing causing it to fail because of bad_auth #97

Open
RaumTora opened this issue Jan 7, 2025 · 2 comments

Comments

@RaumTora
Copy link

RaumTora commented Jan 7, 2025

I was working on integrating albedo in my dapp using the albedo intent library.

But when I create signature using the Albedo Intent tx , it fails due to bad AUTH but when done using the stellar sdk signing using secret keypair , it works fine.

Attaching my code snippet for reference for the functions that I am using -

`// src/services/staking.ts

import { AlbedoWallet } from '@/services/wallets/AlbedoWallet';
import { nativeToScVal, Horizon, rpc, TransactionBuilder, Networks, Contract, Transaction } from 'stellar-sdk';

const STAKING_CONTRACT_ADDRESS = 'CD4NK6ZV6MGJBQZA66LJPTM5NMDFLHYLBUCDMTG5KK223D2DLVULXJ5H';

export const stakeAssets = async (amount: string, wallet: AlbedoWallet) => {
try {
// Ensure the wallet is connected
const address = await wallet.getPublicKey();
if (!address) {
throw new Error("Wallet is not connected");
}

    // Create a Stellar SDK server instance
    const server = new rpc.Server('https://soroban-testnet.stellar.org:443');

    // Load the account
    const account = await server.getAccount(address);
    console.log("Loaded account:", account);

    const contract = new Contract(STAKING_CONTRACT_ADDRESS);

    // Create a transaction
    const transaction = new TransactionBuilder(account, {
        fee: '100',
        networkPassphrase: Networks.TESTNET,
    })
        .addOperation(contract.call("stake_eth", ...[
            nativeToScVal(address, { type: "address" }),
            nativeToScVal(amount, { type: "i128" }),
        ]))
        .setTimeout(500)
        .build();

    console.log("Built transaction:", transaction);

    let preparedTransaction = await server.prepareTransaction(transaction);
    console.log("Prepared transaction:", preparedTransaction);
    
    const data = await wallet.signTransaction(preparedTransaction);
    console.log("Signed transaction:", data);
    
    // Submit the transaction
    const result = await server.sendTransaction(preparedTransaction);
    console.log("Transaction successful:", result);
    return result;
} catch (error) {
    console.error("Staking transaction failed:", error);
    throw error;
}

};
`

Albedo Sign Transaction -

`async signTransaction(transaction: Transaction): Promise {
if (!this.publicKey) {
throw new Error('Wallet not connected');
}

try {
  const result = await albedo.tx({
    xdr: transaction.toXDR(),
    network:'testnet'
  });
  return result.signed_envelope_xdr;
} catch (error) {
  console.log(error);
  throw new Error('Failed to sign transaction');
}

}`

Any help would be appreciated.

CaptuSSre

@Dammykhay12344
Copy link

Hello @RaumTora
You’re on the Testnet network? Correct?

@RaumTora
Copy link
Author

RaumTora commented Jan 7, 2025

Hello @RaumTora You’re on the Testnet network? Correct?

Yes , I am on Testnet @Dammykhay12344

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@RaumTora @Dammykhay12344 and others