0
  const lamports = 0.001 * 10 ** 9;
  const fromPubKey = new PublicKey(
    'Wallet sending here'
  );
  const toPubKey = new PublicKey(
    'Wallet receiving here'
  );

  const transaction = new Transaction().add(
    SystemProgram.transfer({
      fromPubkey: publicKey,
      toPubkey: toPubKey,
      lamports,
    })
  );

  const {
    context: { slot: minContextSlot },
    value: { blockhash, lastValidBlockHeight },
  } = await connection.getLatestBlockhashAndContext();

  try {
    const signature = await sendTransaction(transaction, connection, {
      minContextSlot,
    });

    loadingToast.current = toast.loading('Transaction loading...');
    await connection.confirmTransaction({
      blockhash,
      lastValidBlockHeight,
      signature,
    });

  } catch (e) {
    console.log(e);
    toast.error('Error, please try again!');
  }

I have this code written in a NextJS app. Using @solana/wallet-adapter-react to connect to my phantom wallet.

Everything is working fine when testing locally, and also when passing through ngrok (to provide ssl and https)

Working

However, when I deploy my app to aws amplify (since its nextjs), when trying to send 0.001 SOL, phantom is giving me this error

Not working :(

My deployed app on aws also has SSL and HTTPS configured properly.

3
  • In the screenshot the URL under Approve transaction text is pointing to the ngrok URL. Maybe that needs to be changed and point it to some AWS URL? Also, make sure your app is launched on process.env.PORT instead of any hardcoded port number. If you are using some added environment variables then also make sure to add them in AWS env settings. Jan 15 at 13:50
  • @AbdullahQureshi Yes because with the ngrok, it is working, however on the aws deployed website, it is not. Really strange
    – Kob3Bryant
    Jan 15 at 15:15
  • have you looked into process.env.PORT. Is server up or crashed? check AWS logs. Also, check Solana Explorer logs. Jan 15 at 15:32

1 Answer 1

1

In the next.config.js Remove the swcMinify: true

Worked!

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.