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)
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
My deployed app on aws also has SSL and HTTPS configured properly.
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 onprocess.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.process.env.PORT
. Is server up or crashed? checkAWS
logs. Also, check Solana Explorer logs.