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. Commented Jan 15, 2023 at 13:50
  • @AbdullahQureshi Yes because with the ngrok, it is working, however on the aws deployed website, it is not. Really strange
    – Kob3Bryant
    Commented Jan 15, 2023 at 15:15
  • have you looked into process.env.PORT. Is server up or crashed? check AWS logs. Also, check Solana Explorer logs. Commented Jan 15, 2023 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 you have read our privacy policy.

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